Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 o o o the month must be in the interval [1, 12] the year must be in the interval [1900, 2019] . 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 o The person's name and age in years and months o If the person's age is over 65 it printsYou are a senior. lf the person's age is under 18 it prints "You are a kid. o Otherwise (if age is between 18 and 65, inclusive) it prints "You are an adult o 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: the logic of your program (see Fig. 5.6, https://en wikipedia org/wiki/Flowchart) Use Age,java as a starter code . Use the Type class Type.java) to check for the type of the input. See how this is implemented in Checklnput,java. 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): Implement a loop for asking the user to reenter the input until it is of the correct type and in the allowed range. See Grade,java Submission: Submit a single Word or PDF file with a project report containg the following items: 1. The source code of the program. 2. The flowchart of the logic of your program. 3. A screen copy of the BlueJ main window showing the classes used by the program. 4. A screen copy of the BlueJ Terminal Window showing an example run of your program. Grade.java v Reading a grade until it is in the required range Suggested exercises: Add an input type verification (use Type.java) import java.util.Scanner: public class Grade public static void main (String[] args) Scanner scan new Scanner(System.in): Boolean done false; int grade 0; while (!done) System.out.print("InEnter a grade [0,1001: ) gradescan.nextInt); if (grade>-0 && grade 10)): /I Check intervals if statement 1auntbngs to 10,101*): Syatemout printlola" does not belong to (e,10]") /1 Check intervals if-else statement System.out.println(a +"belongs to (0,10]"); el Syaten.out printlnfa +" does not belong to te,101"); // Check for input type System.out.print("nEnter an item:") input - scan.nextO: ystenout.printin"Integer: +Type. isInteger(input))l aten..outsprinttn-("Double : " + Type . sDouble (input )); if (Type.isinteger(input)) e an.9ut.print.lafinput +"is of type Integer"): eLse if (Type. isDouble(input)) Syaten.out Rrint.lo(input+"is of type Double") Syatem.out print.la( input +"is of type String") else I/ Get the numeric value from string using a wrapper class method if (Type.isIntegerlinput)) Svatsn.out.printla The vatue of the integer + 1 is" (Integer.parseInt(input)+1))
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