Constraints:

  • Display any numerical output with 2 digits after the decimal point
  • DO NOT use break and continue
  • DO NOT use exit() to exit a program
  • All attributes must be defined as private

1. Write the code to define a class named Person. The attributes and methods are:

  • First name - String
  • Last name - String
  • Gender - one-character value such as M or F
  • Weight - double
  • A constructor setting initial values to the attributes - Pick your own data
  • A constructor that accepts as parameters values for the attributes
  • SETTER methods
  • GETTER methods
  • A __str__ method to display the values of the attributes for a Person.

2. Write the code to define a class named Student. This class will inherit from the Person class. The attributes and methods are:

  • Status - String such as freshman, sophomore, junior, or senior
  • A constructor setting initial value to the attribute and call the super class's constructor to initialize the Persons attributes
  • A parametrized constructor to set values to all required attributes
  • SETTER methods
  • GETTER methods
  • A __str__ method to display the value of the attribute for a student

3. Write the code to define a class named Staff. This class will inherit from the Person class. The attributes and methods are:

  • Staff Identification number
  • Salary
  • A constructor setting initial values to the attributes
  • A parametrized constructor to set values to all attributes
  • SETTER methods
  • GETTER methods
  • A __str__ method to display the value of the attributes for a staff

4. Show the usage of your classes by defining various objects that uses the constructors and your methods. At a minimum, we will need:

  • 2 objects from the Person class
  • 2 objects the Student class.
  • 2 objects the Staff class.
  • Allow for input for the attributes and show the results after exercising your methods
  • Make sure to show usage of your GETTER and SETTER methods

Sample run1 must produce the following output:

Person: Alan Turing Gender: M Weight: 150.0
- Student: Person: Carol Shaw Gender: F Weight: 120.0 status: senior
- Staff: Person: Ada Lovelace Gender: F Weight: 135.0 Identification number: 1234 Salary: 5500.55

Another sample interaction

Person: Alan Turing Gender: M Weight: 150.0
- Student: Person: Carol Shaw Gender: F Weight: 120.0 status: senior
- Staff: Person: Ada Lovelace Gender: F Weight: 135.0 Identification number: 1234 Salary:
5500.55

Using my constructor: Person: foo bar Gender: M Weight: 160.0
Enter the first name of a person: jack
Enter the last name of a person: reacher
Enter the gender of a person (M/F): M
Enter the weight of a person: 120
Person: jack reacher Gender: M Weight: 120.0


Using my constructor - My student is: - Student: Person: foo bar Gender: M Weight: 160.0
status: freshman

Enter your class standing: senior
- Student: Person: jack reacher Gender: M Weight: 120.0 status: senior

Using my constructor - My Staff person is: - Staff: Person: foo bar Gender: M Weight: 160.0
Identification number: 9999 Salary: 1000.0

Enter your Identification number: 12345678
Enter your salary: 1200.9
- Staff: Person: jack reacher Gender: M Weight: 150.0 Identification number: 12345678 Salary:
1200.9

Enter a new salary for your employee: 5000.98
Updated employee information:
- Staff: Person: foo bar Gender: M Weight: 160.0 Identification number: 9999 Salary: 5000.98
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.