Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Create a Business class. This class should store an array of Employee objects. Add a method to add employees to the Business, similar to

4. Create a Business class. This class should store an array of Employee objects. Add a method to add employees to the Business, similar to addFoodItem in the Meal class. Add two more methods for the Business class: getHighestPaid(), which returns the Employee who has been paid the most in total, and getHighestTaxed(), which returns the Employee who has been taxed the most in total. Note: you do not need to handle the case of ties.

These are all the given and needed classes.

public class Employee extends Person { double weeklyBaseSalary; double totalPaid; double totalTaxed; public Employee(String iName, int iAge, double baseSal) { super(iName, iAge); this.weeklyBaseSalary = baseSal; } /* * Should update the total amount paid/taxed for this employee. * Taxes should be 10% of the weekly base salary for employees under the age of 30 * and 15% for employees aged 30 or older. * The total paid to the employee should be the amount remaining after taxes are paid */ public void pay() { if (getAge() < 30) { totalTaxed = 0.10 * weeklyBaseSalary; } else { totalTaxed = 0.15 * weeklyBaseSalary; } totalPaid = weeklyBaseSalary - totalTaxed; } /* * Should return a String representing the employees pay cheque. * The pay cheque must contain the following information: the employees name and age, * the weekly base salary, the amount paid in taxes, the amount paid to the employee. */ public String makePaycheque() { String result = ""; result += "Name: " + getName() + ", Age: " + getAge() + " "; result += "Weekly base salary: " + weeklyBaseSalary + " "; result += "Amount paid in taxes: " + totalTaxed; result += "Amount paid to the employee: " + totalPaid; return result; } //Add any additional methods you require here }

public class Person{ private String name; private int age;

public Person(String iName, int iAge){ name = iName; age = iAge; }

public String getName(){ return name; }

public int getAge(){ return age; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions