-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmuWorkingHours.java
More file actions
42 lines (42 loc) · 1.48 KB
/
EmuWorkingHours.java
File metadata and controls
42 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.example;
import java.util.Scanner;
public class EmuWorkingHours {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter a number of Employees : ");
int row = input.nextInt();
System.out.println("Enter a working hours for each employees : ");
int[][] emu = new int[row][7];
for(int i = 0 ; i < emu.length;i++){
System.out.print("Enter emu " + (i+1) + "'s working hours : ");
for(int j = 0 ; j < emu[i].length ; j++){
emu[i][j] = input.nextInt();
}
}
int[] workingHours = new int[row];
int[] workingHoursOccrance = new int[row];
for(int i = 0 ; i < emu.length;i++){
int sum = 0;
for(int j = 0 ; j < emu[i].length ; j++)
sum += emu[i][j];
workingHoursOccrance[i] = i;
workingHours[i] = sum;
}
for(int i = 1 ; i < workingHours.length ; i++){
for(int j = 0 ; j < workingHours.length - i ; j++){
if(workingHours[j] > workingHours[j+1] ){
int temp = workingHours[j];
workingHours[j] = workingHours[j+1];
workingHours[j+1] = temp;
int tem = workingHoursOccrance[j];
workingHoursOccrance[j] = workingHoursOccrance[j+1] ;
workingHoursOccrance[j+1] = tem;
}
}
}
System.out.println("Employee " + "\t total working hours in week ");
for(int i = 0 ; i < workingHours.length ; i++){
System.out.println((workingHoursOccrance[i] + 1)+ " " + workingHours[i]);
}
}
}