Problem

Declaring and Initializing Java Variables In this lab, you declare and initialize varia...

Declaring and Initializing Java Variables

In this lab, you declare and initialize variables in a Java program provided with the data files for this book. The program, which is saved in a fie named NewAge. java, calculates your age in the year 2050.

1. Open the source code file named NewAge. java using Notepad or the text editor of your choice.

2. Declare an integer variable named newAge.

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

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

5. Save this source code file in a directory of your choice, and then make that directory your working directory.

6. Compile the source code file NewAge. java.

7. Execute the program. Record the output of this program. _____________________________________________________________________________________ _____________________________________________________________________________________

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 2
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT