The following table shows the various services offered by a hair salon, including its prices and times required:
Service Description Price ($) Time (Minutes)
Cut 8.00 15
Shampoo 4.00 10
Manicure 18.00 30
Style 48.00 55
Trim 6.00 5
Create a class that holds the service description, price, and number of minutes it takes to perform the service. Include a constructor that requires arguments for all three data fields and three get methods that each return one of the data field’s values. Save the class as Service.
Create a second class called SalonReport which has three attributes:
• A single-dimensional array that can hold five Service objects. Fill the array with the data from the table above.
• Number of employees
• A two dimensional array that will hold the number of each type of service each employee in the salon has conducted.
SalonReport should have the following methods:
• A constructor which takes the number of employees as a parameter
• InsertService(int serviceNo, int employeeNo, int total) – the insert service method will take in the number of times a service was conducted for a particular service and employee. You can assume the numbers passed in for the service and employee are valid indexes for the 2D array.
• calculateServiceTotalByEmployee(int serviceNo, int employeeNo) – returns the total amount earned for a particular employee and particular service. Like the last method, you can assume the numbers passed in are the index of the service and employee.
• calculateServiceTotal(int serviceNo) – returns the total amount earned for a particular service for all employees. (Assume serviceNo is a valid index to the array).
• calculateSalontTotal() – returns the total amount earned for all services for all employees.
Test your two classes with the driver class provided :
public class Tester02
public static void main(String args)
SalonReport sr = new SalonReport(2);
sr.insertService(0, 0, 2);
sr.insertService(1, 0, 3);
sr.insertService(2, 0, 3);
sr.insertService(3, 0, 1);
sr.insertService(4, 0, 2);
sr.insertService(0, 1, 4);
sr.insertService(1, 1, 2);
sr.insertService(2, 1, 0);
sr.insertService(3, 1, 2);
sr.insertService(4, 1, 1);
/* Should print 12 */
/* Should print 6 */
/* Should print 32 */
/* Should print 20 */
/* Should print 144 */
/* Should print 284 */