Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the UML diagram above the super class Person has two sub classes : Student and Person. The instance variables and methods are as shown.

image text in transcribed

In the UML diagram above the super class Person has two sub classes : Student and Person. The instance variables and methods are as shown. All instance variables are of the type protected.

The student class overrides the calculateTax method as described in the Person class. In the person class this method return a tax value = 0.12*income . In the student class, this method returns a 0.0, as students are tax exempt.

The UML only shows constructors that take in one value of String , which is the SSN. However, feel free to add a default and full-arg constructor as needed .

Write the classes Person, Employee and Student. Also write a client class called TestPerson, that contains a menu driven program and that will do the following at the minimum,

1) Ask the user to enter the choice: 1 for Employee and 2 for Student.

2) If the choice is 1: create an Employee object and set all the instance variables. You need to get the SSN, email and salary from the user. Set the income to be equal to the salary. Output the values of each instance variable and display the tax amount, by calling the calculateTax method.

3) If the choice is 2: create a Student object and set all the instance variables. You need to get the SSN, Email and stipend from the user. Set income to be equal to the stipend. Output the values of each instance variable and display the tax amount by calling the calculateTax method.

Person # ssn: String Fincome: double #email. String +Person(String) +getincome0: double +getEmailString +setlncome(double):void +setEmail (String) void +calculateTax:double +getSSNO:String Student Employee + stipend: double +Student(String) +getStipend: double + setStipend(double): void +calculateTax:double + salary: double +Employee (String) +getSalary0: double +setSalary0.double

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions