Declare and initialize an integer variable named


Declaring and initializing Java Variables

Calculate your age in the year 2060.

1. Declare an integer variable name newAge.

2. Declare and initialize an integer variable named currentAge. Initialize this variable with your current age.

3. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the currentYear. Use four digits for year. Use four digits for the year.

4. Compile the source code file Newage.java.

5. Execute the program. Record the output of this program.

I will be using java and jGrasp to complile and execute the program. Below is one of the file I down loaded from my book to give me some practice.
I just need help trying to figure out where I put my age and the year. Do I change any of the items below? I am taking an online course and really wish I would have taken this is class. My age to use is 43 and the year is course is 2012. I have a couple of assignments to do and if I can understand this one below I should be able to do the ones for class. Let me know if you need anything else.

// This program calculates your age in the year 2060.
// Input: None.
// Output: Your current age followed by your age in 2060.

publicclassNewAge
{
publicstaticvoid main(String args[])
{
// Declare and initialize your variables here.


newAge = currentAge + (2060 - currentYear);

System.out.println("My Current Age is " + currentAge);
System.out.println("I will be " + newAge + " in 2060.");

System.exit(0);
}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Declare and initialize an integer variable named
Reference No:- TGS01249657

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)