-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ030.java
More file actions
65 lines (56 loc) · 1.74 KB
/
J030.java
File metadata and controls
65 lines (56 loc) · 1.74 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.Scanner;
public class J030{
public static void main(String[] args){
J030 pStudio = new J030();
pStudio.J030();
}
public void J030(){
Scanner s = new Scanner(System.in);
String[] names = {"James","David","Simon","Peter","Jason"};
int[][] sheet = new int[5][10];
int[] answer = {1,2,3,4,1,2,3,4,3,2};
int[] grade = new int[5];
int count = 0;
int count1 = 0, count2 = 0, count3 = 0;
for(int i=0; i<5; i++){
for(int j=0; j<10; j++){
sheet[i][j] = s.nextInt();
if(sheet[i][j] == answer[j])
count++;
}
if(count == 9 || count == 10)
grade[i] = 1;
else if(count == 7 || count == 8)
grade[i] = 2;
else if(count <= 6)
grade[i] = 3;
count = 0;
}
for(int i=0; i<5; i++){
if(grade[i] == 1)
count1++;
else if(grade[i] == 2)
count2++;
else
count3++;
}
System.out.printf("1st : ");
for(int i=0; i<5; i++)
if(grade[i] == 1){
System.out.printf("%s ",names[i]);
}
System.out.printf("(%d)\n",count1);
System.out.printf("2nd : ");
for(int i=0; i<5; i++)
if(grade[i] == 2){
System.out.printf("%s ",names[i]);
}
System.out.printf("(%d)\n",count2);
System.out.printf("Fail : ");
for(int i=0; i<5; i++)
if(grade[i] == 3){
System.out.printf("%s ",names[i]);
}
System.out.printf("(%d)\n",count3);
}
}