Answered step by step
Verified Expert Solution
Link Copied!

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

image

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... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions