Answered step by step
Verified Expert Solution
Link Copied!

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.

  1. 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";
  2. Create an int variable named myAge and assign your age in years to it. ( Or any valid age if this is considered personal )
  3. 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.
  4. Create an int variable named myAgeIn2040 and assign it the result of 2040 - currentYear + myAge;
  5. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago