Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that computes weekly hours for each employee. Store the weekly hours for all employees in a two - dimensional array. Each row

Write a program that computes weekly hours for each employee. Store the weekly hours for all employees in a two-dimensional array. Each row records an employee's seven-day work hours with seven columns. For example, the following array stores the work hours for eight employees. Display employees and the total hours of each employee in decreasing order of the total hours.
\table[[,Su,M,T,W,R,F,Sa],[Employee0,2,4,3,4,5,8,8],[Employee1,7,3,4,3,3,4,4],[Employee2,3,3,4,3,3,2,2],[Employee3,9,3,4,7,3,4,1],[Employee4,3,5,4,3,6,3,8],[Employee5,3,4,4,6,3,4,4],[Employee6,3,7,4,8,3,8,4],[Employee7,6,3,5,9,2,7,9]]
Requirements:
Design a method that takes the 2-D array of weekly hours of all employees as an input parameter, calculates the sum of the total hours of all employees and returns the total hour results in an array.
Design a method to sort the above returned array in Requirement 1 in descending order by selection sort.
Important: when sorting the array, the program should keep track of which employee corresponds to how many work hours. Therefore, you should store the employee information in an array and return it as a result of your sort method.
Design a method to display the results of employees and their total hours in decreasing order. The sample output for the above example is as follows:
Design a main method that uses the short hand initializer to initialize the 2-D array of weekly hours of all employees and invokes all the three methods in Requirements 1-3 in a sequence. How to hand in the assignment
When you finish your assignment, you will upload (submit) it to Gradescope. I remind you that
submit the assignment before the due date, you will not be able to submit it.
Complete the assignment and name it HW8.
Return to the Gradescope to submit the .java file for this assignment.
Browse for the HW8.java file that you have on your computer and select it so that it upl
assignment area.
Click "Upload".
For this assignment, please name your class file as "HW8"
package homework;
public class HW8{
public static void main(String[] args){
int[][] workHours
{2,4,3,4,5,8,8},
{7,3,4,3,3,4,4},
{3,3,4,3,3,2,2},
{9,3,4,7,3,4,1},
{3,5,4,3,6,3,8},
{3,4,4,6,3,4,4},
{3,7,4,8,3,8,4},
{6,3,5,9,2,7,9}
} ;
int[] sumArray = calculateSum(workHours);
int[] indexArray = decreasingSort(sumArray);
displayArray(indexArray, sumArray);
}
public static int[] calculateSum (int[][] array){
//Please write your code here
} Finally, your code's formatting should look exactly like the output mentioned below and should be able to
run/ compile.
Employee7: 41 hours
Employee6: 37 hours
Employee0: 34 hours
Employee4: 32 hours
Employee3: 31 hours
Employee5: 28 hours
Employee1: 28 hours
Employee2: 20 hours
-JAVA AND EXACT OUTPUT PLEASE
image text in transcribed

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

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago