Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this exercise, we will create some variables and work with String methods. This task should be done completely in the main() method. Create a
For this exercise, we will create some variables and work with String methods.
This task should be done completely in the main() method.
- Create a String variable named myName and assign your name to it. Include your first and last name. Use proper name cases - Uppercase first letter, lowercase remaining letters - as in "Morgan Freeman";
- Create an int variable named myAge and assign your age in years to it. ( Or any valid age if this is considered personal )
- Create an int variable named currentYear and assign it the result of LocalDate.now().getYear(); This statement will require an import for the LocalDate class.
- Create an int variable named myAgeIn2040 and assign it the result of 2040 - currentYear + myAge;
- Using System.out, create a display similar to the following. Use the variables myName and myAge in the display code. Use the available public String method to generate the uppercase version of your name.
MORGAN FREEMAN will be 102 in the year 2040.
5 points extra credit:
Create a constant to store 2040 and use the constant in the calculation and display. Name the constant using a descriptive name and with the constant naming format.
Deliverable is a working Java program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started