-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradeCalculator3.java
More file actions
67 lines (57 loc) · 3.46 KB
/
Copy pathGradeCalculator3.java
File metadata and controls
67 lines (57 loc) · 3.46 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
import javax.swing.JOptionPane;
public class GradeCalculator3 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
JOptionPane.showMessageDialog(null, "Student " + i);
while (true) {
try {
double attendanceScore = Double.parseDouble(JOptionPane.showInputDialog("Enter Attendance Score (0-11):"));
double assignmentScore = Double.parseDouble(JOptionPane.showInputDialog("Enter Assignment Score (0-120):"));
double quizScore = Double.parseDouble(JOptionPane.showInputDialog("Enter Quiz Score (0-132):"));
double labActivityScore = Double.parseDouble(JOptionPane.showInputDialog("Enter Laboratory Activity Score (0-200):"));
double examScore = Double.parseDouble(JOptionPane.showInputDialog("Enter Exam Score (0-100):"));
if (attendanceScore < 0 || attendanceScore > 11 ||
assignmentScore < 0 || assignmentScore > 120 ||
quizScore < 0 || quizScore > 132 ||
labActivityScore < 0 || labActivityScore > 200 ||
examScore < 0 || examScore > 100) {
JOptionPane.showMessageDialog(null, "Error: Please enter valid scores within the specified ranges.");
continue;
}
double attendanceWeighted = (((attendanceScore / 11) * 60) + 40) * 0.10;
double assignmentWeighted = (((assignmentScore / 120) * 60) + 40) * 0.15;
double quizWeighted = (((quizScore / 132) * 60) + 40) * 0.20;
double labActivityWeighted = (((labActivityScore / 200) * 60) + 40) * 0.25;
double examWeighted = (((examScore / 100) * 60) + 40) * 0.30;
double totalWeightedScore = attendanceWeighted + assignmentWeighted + quizWeighted + labActivityWeighted + examWeighted;
String equivalentGrade;
if (totalWeightedScore >= 96) {
equivalentGrade = "1.0";
} else if (totalWeightedScore >= 93) {
equivalentGrade = "1.25";
} else if (totalWeightedScore >= 90) {
equivalentGrade = "1.50";
} else if (totalWeightedScore >= 87) {
equivalentGrade = "1.75";
} else if (totalWeightedScore >= 84) {
equivalentGrade = "2.0";
} else if (totalWeightedScore >= 81) {
equivalentGrade = "2.25";
} else if (totalWeightedScore >= 78) {
equivalentGrade = "2.75";
} else if (totalWeightedScore >= 75) {
equivalentGrade = "3.0";
} else if (totalWeightedScore >= 70) {
equivalentGrade = "4.0";
} else {
equivalentGrade = "5.0";
}
JOptionPane.showMessageDialog(null, String.format("Student %d\nTotal Weighted Score: %.2f\nEquivalent Grade: %s", i, totalWeightedScore, equivalentGrade));
break;
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Error: Please enter valid numeric values.");
}
}
}
}
}