469,898 Members | 1,801 Online

# 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 ();

int age;

c.print("Hello, what is your name?");
c.println();
c.println(userName + ", what is the current year?");
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
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 ();

int age;

c.print("Hello, what is your name?");
c.println();
c.println(userName + ", what is the current year?");
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
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