Question: Write a program in Java and run it in BlueJ according to the following specifications: The program first asks the user for his/her name and
Write a program in Java and run it in BlueJ according to the following specifications:
The program first asks the user for his/her name and then for the month and year of his/her birth.
Then the program validates the input by checking the following conditions:
the input for month and year must be of integer type
the month must be in the interval [1, 12]
the year must be in the interval [1900, 2017]
If any one of these conditions is not satisfied the program must print a proper message indicating which condition is not met and terminate after that.
If the input is correct the program computes the age of the person and prints:
The person's name and age in years and months
If the person's age is over 65 it prints "You are a senior"
If the person's age is under 18 it prints "You are a kid"
Otherwise (if age is between 18 and 65, inclusive) it prints "You are an adult".
Finally, if the person's birth month is the same as the current month, the program prints a happy birthday greeting that includes the person's name too.
Requirements and restrictions:
Draw a flowchart of the logic of your program (see Fig. 5.6, https://en.wikipedia.org/wiki/Flowchart).
Use the scanner class for input.
Use the Type class (Type.java) to check for the type of the input. See CheckInput.java for help.
Use proper names for the variables suggesting their purpose.
Format your code accordingly using indentation and spacing.
Use multiple line comment in the beginning of the code and write your name, e-mail address, class, and section.
For each line of code add a short comment to explain its meaning.
Extra credit (up to 2 points) will be given for implementing a loop for asking the user to reenter the input until it is of the correct type and in the allowed range.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
