Stranded in this easy program. . . .
Q : Write a program that displays employ-ees and their total hours in decreasing order of the total hours
my working. . .
{I was not able to print the employee individual hours according to 'decreasing order' .How can i do that ?}
PHP Code:
import java.util.Scanner;
public class EmployeeWeeklyHours {
public static void main(String[] args){
System.out.println("Enter employee weekly hours: ");
int[][] employeeHours=employeeWeeklyHour();
int[] storeEmployeeTotalHours =employeeTotalHours(employeeHours);
System.out.println("\t\tSun\tMon\tTue\tWed\tThur\tFri\tSat");
dispEmployeeWeeklyHoursFromHighest(employeeHours);
}
public static int[][] employeeWeeklyHour(){
Scanner input = new Scanner(System.in);
int[][] employeeHours = new int[8][7];
for(int i=0;i<employeeHours.length;i++)
for(int j=0;j<employeeHours[i].length;j++)
employeeHours[i][j]=(int) (51 + Math.random()*50); //input.nextInt();
return employeeHours;
}
public static int[] employeeTotalHours(int[][] findTotalHours){
int[] storeEmployeeTotalHours = new int[findTotalHours.length];
for(int i=0;i<findTotalHours.length;i++)
for(int j=0;j<findTotalHours[i].length;j++)
storeEmployeeTotalHours[i] +=findTotalHours[i][j];
return storeEmployeeTotalHours;
}
public static void dispEmployeeWeeklyHoursFromHighest(int[][] hoursPerWeek){
for(int i=0;i<hoursPerWeek.length;i++){
System.out.print("Employee "+i+" :\t");
for(int j=0;j<hoursPerWeek[i].length;j++){
System.out.print(hoursPerWeek[i][j]+"\t");
}
System.out.println();
}
}
}