-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentarray
More file actions
98 lines (87 loc) · 2.59 KB
/
studentarray
File metadata and controls
98 lines (87 loc) · 2.59 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package StudentArray;
import java.util.Arrays;
import javax.swing.JOptionPane;
public class studentarray {
public static void main(String[] args) {
String[] StudentNames;
StudentNames = new String[20];
int count = 20;
for (int i = 0; i < count; i++) {
StudentNames[i] = JOptionPane
.showInputDialog("Enter your student's names:");
// System.out.println(Arrays.toString(StudentNames));
}
JOptionPane.showMessageDialog(null, "Now enter the percentages");
int[][] StudentScores = new int[20][5];
int j = 0;
for (int k = 0; k < 5; k++) {
for (; j < count; j++) {
String sScoreRaw = JOptionPane
.showInputDialog("Enter your student's percentages");
StudentScores[j][k] = Integer.valueOf(sScoreRaw);
// System.out.println(Arrays.deepToString(StudentScores));
}
if (j == count) {
int response = JOptionPane
.showConfirmDialog(null,
"Do you want to continue entering results?",
"Confirm", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
j = 0;
} else if (response == JOptionPane.NO_OPTION) {
break;
}
}
}
String[][] StudentGrades = new String[20][5];
for (int l = 0; l < 5; l++) {
for (int m = 0; m < count; m++) {
int sScore = StudentScores[m][l];
if (sScore <= 40)
StudentGrades[m][l] = "U";
else if (sScore <= 50)
StudentGrades[m][l] = "E";
else if (sScore <= 60)
StudentGrades[m][l] = "D";
else if (sScore <= 70)
StudentGrades[m][l] = "C";
else if (sScore <= 80)
StudentGrades[m][l] = "B";
else if (sScore <= 90)
StudentGrades[m][l] = "A";
else if (sScore <= 100)
StudentGrades[m][l] = "A*";
else
JOptionPane.showMessageDialog(null,
"Error ID: 10T, Percentage too high", "Error",
JOptionPane.ERROR);
}
if (l == 4){
break;
}
}
System.out.println("ey");
for (int n = 0; n < 20; n++) {
System.out.print(StudentNames[n]);
System.out.print("\t");
System.out.print("\t");
System.out.print(StudentScores[n][0]);
System.out.print("\t");
System.out.print(StudentGrades[n][0]);
System.out.print("\t");
System.out.print(StudentScores[n][1]);
System.out.print("\t");
System.out.print(StudentGrades[n][1]);
System.out.print("\t");
System.out.print(StudentScores[n][2]);
System.out.print("\t");
System.out.print(StudentGrades[n][2]);
System.out.print("\t");
System.out.print(StudentScores[n][3]);
System.out.print("\t");
System.out.print(StudentGrades[n][3]);
System.out.print("\n");
}
}
}