469,898 Members | 1,801 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Output problem

heres my code there 1 problem with it (its bolded) its not going through its a math type things if any one can help me please help all i ask is that you no change the code too much if possible, heres my instructions:

Write a Java program that will do the following:
* ask the user to input their name and age
* ask the user to input the current year
* determine their age in year 2050
* display their name, their current age and their age in 2050 as user-friendly output



heres my code:




// The "AgeIn2050" class.
//Bob Jones
//Tuesday, Febuary 27, 2007
import java.awt.*;
import hsa.Console;

public class AgeIn2050
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

String userName,yearCurrent;
int age;

c.print("Hello, what is your name?");
userName = c.readString();
c.println();
c.println(userName + ", what is the current year?");
yearCurrent = c.readString();
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
age = c.readInt();
c.println();

c.println(userName + ", you are currently " + age + ", in the year " + 2050 + ", you will be " + ((2050 - yearCurrent) + (+ age)) ".");
} // main method
} // AgeIn2050 class
Feb 28 '07 #1
1 1218
r035198x
13,262 8TB
heres my code there 1 problem with it (its bolded) its not going through its a math type things if any one can help me please help all i ask is that you no change the code too much if possible, heres my instructions:

Write a Java program that will do the following:
* ask the user to input their name and age
* ask the user to input the current year
* determine their age in year 2050
* display their name, their current age and their age in 2050 as user-friendly output



heres my code:




// The "AgeIn2050" class.
//Bob Jones
//Tuesday, Febuary 27, 2007
import java.awt.*;
import hsa.Console;

public class AgeIn2050
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

String userName,yearCurrent;
int age;

c.print("Hello, what is your name?");
userName = c.readString();
c.println();
c.println(userName + ", what is the current year?");
yearCurrent = c.readString();
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
age = c.readInt();
c.println();

c.println(userName + ", you are currently " + age + ", in the year " + 2050 + ", you will be " + ((2050 - yearCurrent) + (+ age)) ".");
} // main method
} // AgeIn2050 class
Try


Expand|Select|Wrap|Line Numbers
  1.  
  2. c.println(userName + ", you are currently " + age + ", in the year 2050, you will be " + ((2050 - yearCurrent) + age)+ ".");
  3.  
  4.  
Feb 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Lisa | last post: by
5 posts views Thread by Tom Lam lemontea | last post: by
6 posts views Thread by Alec MacLean | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.