Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is java: Main.javause onlinegdb.com to create the codeplease show the picture of the code Write a Person class with the following attributes: Name Age
this is java: Main.javause onlinegdb.com to create the codeplease show the picture of the code
Write a Person class with the following attributes: Name Age The class person should have constructors, get and set methods. Define two unchecked exceptions with constructors that take a message of String. It should pass the message to the super class. InvalidNameException InvalidAgeException Update the Person class so that set methods will check the values of the parameters. For example, the name must not be an empty string and the age must be a number between 0 and 130. If the name is empty, it should throw InvalidNameException. If the age is invalid, it should throw InvalidAgeException. The constructor should use these two set methods when initialize the instance variables with values of the parameters. Write a main class that prompts the user to create three person objects. It should handle any exceptions so that the user must enter only valid input. If an exception occurs, it should prompts for the information for that person again.
Step by Step Solution
★★★★★
3.39 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
import javautilScanner class InvalidNameException extends RuntimeException public InvalidNameExcepti...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