Problem

Declaring and Initializing Java Constants In this lab, you declare and initialize cons...

Declaring and Initializing Java Constants

In this lab, you declare and initialize constants in a Java program provided with the data files for this book. The program, which is saved in a file named NewAge2 j ava, calculates your age in the year 2050.

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

2. Declare a constant named YEAR, and initialize YEAR with the value. 2050.

3. Edit the following statement so it uses the constant named YEAR:

newAge = currentAge + (2050 - currentYear);

4. Edit the following statement so it uses the constant named YEAR:

System. out .pri ntl n ("I will be" + newAge + "in 2050 . ") ;

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 NewAge2.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