Create a class called Person that has instance variables set

Create a class called Person that has instance variables, setters, and getters for the following data members:
- First name
- Last name
- Birth year
- Sex
- Weight in pounds
- Highest education level (can be \"high school\", \"undergraduate\", or \"graduate\")

Create several overloaded constructors, as follow:

1. One constructor takes all six values (above) as parameters
2. Another Constructor takes five values as parameters, but sets the birth year automatically to 2016
3. A third constructor takes three values as parameters, but sets the birth year automatically to 2016, the sex to female, and the highest education level to \"high school\".

In the first two constructors, use a switch statement to ensure that the highest education level is only one of the three specified, and that the sex is either \"male\" or \"female\".

Create overloaded method for:

printDetails()
printDetails(boolean kilograms)
printDetails(boolean uppercase)

All three methods print sentences in the exact format of:

\"Tiger Woods was born in 1975. He weighs 200 pounds and he has an undergraduate degree\"

Note: use \"She\" instead of \"he\" for females

Note: convert to kilograms for the second overloaded method if true is passed in.

Note: print the names out in UPPERCASE in the third overloaded method if true is passed in; otherwise use all lowercase.

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

NOTE: We cannot use overloaded methods by changing only the argument name, overloaded methods are the one which either differ in no:of arguments or differrent argument. So here we can only implement any of one methods below:

printDetails(boolean kilograms)
printDetails(boolean uppercase)

-------------------------------------------------------

OUTPUT:

abc xy was born in 2016. He weighs 72.5 pounds and he has an undergraduate degree
abc xy was born in 2016. He weighs 32.885419999999996 kilos and he has an undergraduate degree

Create a class called Person that has instance variables, setters, and getters for the following data members: - First name - Last name - Birth year - Sex - Wei

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site