Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Person{ private String name; private int age; public Person (String iName, int iAge) { name = iName; age = iAge; public String getName()

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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; } public class Employee extends Person double weeklyBaseSalary; double totalPaid; double totalTaxed; public Employee (String iName, int iAge, double baseSal) { super (iName, iAge); //Code here } e 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 () { //Code here 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 () { //Code here return ""; //only included so code will compile //Add any additional methods you require here public class FoodItem private String name; private int calories; public FoodItem(String iName, int iCals) { name = iName; calories = iCals; } public void setName(String newName) { name = newName; } public void setCalories (int newCals) { calories = newCals; } public int getCalories() { return calories; } public String getName() { return name; } //Represents a meal made up of up to maxItems food items public class Meal { private FoodItem[] items; //stores all of the food items that are in the meal private static final int maxItems = 25; //Constructor should initialize all instance variables public Meal() { //Add the given food item to the items array, if there is still room //If there is no room, do nothing. public void addFoodItem (FoodItem item) { //Return the FoodItem in the items array that has the largest number of calories //If there are ties, you may return any of the largest public FoodItem mostCalories() { return null; //included so code will compile } //Computes and returns the total number of calories of all food items in this meal public int calculateTotalCalories() { return -1; //included so code will compile } public class Customer double money; public Customer() { this initMoney: 0.0); } public Customer (double initMoney) { money - initMoney; } public double getMoney () { return money; } public void setMoney (double newMoney) { money = newMoney; } 1. Given the Person class specified in Person.java file, fill in the code for the Employee class in the Employee.java file. 2. The Foodltem.java file defines a class called FoodItem that contains instance variables for name (String) and calories (int), along with get/set methods for both. Implement the methods in the Meal class found in Meal.java. 3. Consider the Customer class defined in Customer.java, which contains a double money variable. Add an is Richer Than(Customer other) method to the class that returns true if the calling Customer has more money than the Customer specified as an argument. Write a static findRichest(Customer[customers) method that returns the Customer from the argument array that has the most money. Note: you do not need to handle the case of ties. 4. Create a Business class. This class should store an array of Employee objects (use the class defined in Problem 1). Add a method to add employees to the Business, similar to addFoodltem 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. 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; } public class Employee extends Person double weeklyBaseSalary; double totalPaid; double totalTaxed; public Employee (String iName, int iAge, double baseSal) { super (iName, iAge); //Code here } e 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 () { //Code here 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 () { //Code here return ""; //only included so code will compile //Add any additional methods you require here public class FoodItem private String name; private int calories; public FoodItem(String iName, int iCals) { name = iName; calories = iCals; } public void setName(String newName) { name = newName; } public void setCalories (int newCals) { calories = newCals; } public int getCalories() { return calories; } public String getName() { return name; } //Represents a meal made up of up to maxItems food items public class Meal { private FoodItem[] items; //stores all of the food items that are in the meal private static final int maxItems = 25; //Constructor should initialize all instance variables public Meal() { //Add the given food item to the items array, if there is still room //If there is no room, do nothing. public void addFoodItem (FoodItem item) { //Return the FoodItem in the items array that has the largest number of calories //If there are ties, you may return any of the largest public FoodItem mostCalories() { return null; //included so code will compile } //Computes and returns the total number of calories of all food items in this meal public int calculateTotalCalories() { return -1; //included so code will compile } public class Customer double money; public Customer() { this initMoney: 0.0); } public Customer (double initMoney) { money - initMoney; } public double getMoney () { return money; } public void setMoney (double newMoney) { money = newMoney; } 1. Given the Person class specified in Person.java file, fill in the code for the Employee class in the Employee.java file. 2. The Foodltem.java file defines a class called FoodItem that contains instance variables for name (String) and calories (int), along with get/set methods for both. Implement the methods in the Meal class found in Meal.java. 3. Consider the Customer class defined in Customer.java, which contains a double money variable. Add an is Richer Than(Customer other) method to the class that returns true if the calling Customer has more money than the Customer specified as an argument. Write a static findRichest(Customer[customers) method that returns the Customer from the argument array that has the most money. Note: you do not need to handle the case of ties. 4. Create a Business class. This class should store an array of Employee objects (use the class defined in Problem 1). Add a method to add employees to the Business, similar to addFoodltem 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

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