package arreyreview; public class HoursAndPayAngela { public static void main(String[] args) { int [] [] hours = new int [7] [5]; for (int row = 0; row < 7; row++){ for(int col = 0; col < 5; col++){ hours[row][col]= (int) (Math.random()*11); System.out.print(hours[row][col]+" "); } System.out.println(); } System.out.println(); int [] totalEmp = new int [5]; for (int col = 0; col < 5; col ++){ totalEmp[col] = 0; for (int row = 0; row < 7; row ++){ totalEmp[col]+=hours[row][col]; } System.out.println("Total for employee " + col + " is " + totalEmp[col] ); } System.out.println(); int count = 0; for(int row = 0; row < 7; row++){ count = 0; for(int col = 0; col < 5; col ++){ if(hours[row][col]!=0) count+= 1; } System.out.println("On day: " + row + " " + count + " workers worked."); } System.out.println(); } } a) If each employee was paid $20.5 per hour calculate and output the weekly earnings for each employee. b) Calculate and output how much all employees earned together. c) how many employees worked more than 5 hours on Saturday (day with index 6).
package arreyreview;
public class HoursAndPayAngela {
public static void main(String[] args) {
int [] [] hours = new int [7] [5];
for (int row = 0; row < 7; row++){
for(int col = 0; col < 5; col++){
hours[row][col]= (int) (Math.random()*11);
System.out.print(hours[row][col]+" ");
}
System.out.println();
}
System.out.println();
int [] totalEmp = new int [5];
for (int col = 0; col < 5; col ++){
totalEmp[col] = 0;
for (int row = 0; row < 7; row ++){
totalEmp[col]+=hours[row][col];
}
System.out.println("Total for employee " + col + " is " + totalEmp[col] );
}
System.out.println();
int count = 0;
for(int row = 0; row < 7; row++){
count = 0;
for(int col = 0; col < 5; col ++){
if(hours[row][col]!=0)
count+= 1;
}
System.out.println("On day: " + row + " " + count + " workers worked.");
}
System.out.println();
}
}
a) If each employee was paid $20.5 per hour calculate and output the weekly earnings for each employee.
b) Calculate and output how much all employees earned together.
c) how many employees worked more than 5 hours on Saturday (day with index 6).
Step by step
Solved in 3 steps with 2 images