Question
There is an answer to this problem but the number of Hotels and years in that answer is determined; however, in this question, it is
There is an answer to this problem but the number of Hotels and years in that answer is determined; however, in this question, it is supposed to enter the number of employee and years to be interactively and the Value of salary be randomly. Please put the code according to the question.
Program #2 (25 points): Design and implement a Java class (name it SummerStats) that tracks statistics for summer job salaries for a group of employees over several years. The only data field in the class is a twodimensional array of values representing the salaries. The rows represent employees and the columns represent the years. The class constructor method takes two integers representing the number of employees and the number of years, creates the array, randomly generates the annual salaries (between $2,000 and $50,000), and fills the array. The class defines the following methods that take salaries array as a parameter: 1. A method named mostMoney() to return the index of the person having made the most money over the years. 2. A method named highestSalaryYear() to return the index of the year when the highest salary was earned. 3. A method named totalEarnings() to return the total amount of money made by a specified person (i.e., specific row index passed as a parameter to the method ). 4. A method named allEarnings() to return the total amount of money made by all the employees over the years. 5. A method named highestSalaryPerson() to return the index of the person who made the highest salary in a given year (specific by column index passed as a parameter to the method). 6. A method named averageSalaryEachYear() to return a one-dimensional array of the average salary for each year. 7. A method named printSalaries() to print the salaries array(employees data) in tabular format as shown below (the sample output assume 3 employees and 4 years). Write a test program named testSummerStats to create an object of this class and test all of the class methods on that objects. The outputs should be organized as follows (assuming three employees and four years). Note the outputs below the employee data are from each of the methods above in that order. Employee Data: Year1 Year2 Year3 Year4 ----------------------------------------------------------------------------- Employee1 $37,320 $44,320 $14,630 $32,650 Employee2 $17,100 $30,220 $44,550 $31,750 Employee3 $49,300 $48,210 $45,420 $49,800 Employee3 made most money over the years. Highest salary was made in Year4. Total earning by Employee1 is $128,920. Total earning by all Employees is $445,270. In year3, Employee3 has the highest salary. The average salary for year: Year1 Year2 Year3 Year4 ----------------------------------------------------------------------------------- $34,573.33 $40,916.67 $34,866.67 $38,066.67
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started