-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradeApp.java
54 lines (42 loc) · 2.21 KB
/
GradeApp.java
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
import java.util.ArrayList;
import java.util.Scanner;
public class GradeApp {
public static double weightedPsetGrades(ArrayList<Double> psetScores, double totalEc) {
double totalScored = 0;
for (Double score : psetScores) {
totalScored += score;
}
totalScored += totalEc; // Add total extra credit to the sum of pset scores
double totalPointsPossible = 110 + 105 + 80 + 140 + 50 + 75;
double percentageScore = (totalScored / totalPointsPossible) * 100;
double weightedScore = 0.50 * percentageScore;
return weightedScore;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<Double> psetScores = new ArrayList<>();
double totalEc = 0;
// Input problem sets and extra credit
for (int i = 1; i <= 6; i++) {
System.out.println("Enter pset " + i + " grade:");
psetScores.add(scanner.nextDouble());
System.out.println("Enter pset " + i + " extra credit:");
totalEc += scanner.nextDouble();
}
System.out.println("Enter Midterm grade:");
double midtermGrade = scanner.nextDouble() / 50 * 15; // 15% of total
System.out.println("Enter Final grade:");
double finalGrade = scanner.nextDouble() / 100 * 25; // 25% of total
System.out.println("Enter Term Project grade:");
double termProjectGrade = scanner.nextDouble() / 15 * 10; // 10% of total
// Calculating weighted grades with and without extra credit
double weightedPsetGradeWithEc = weightedPsetGrades(psetScores, totalEc);
double weightedPsetGradeWithoutEc = weightedPsetGrades(psetScores, 0);
double finalTotalGradeWithEc = weightedPsetGradeWithEc + midtermGrade + finalGrade + termProjectGrade;
double finalTotalGradeWithoutEc = weightedPsetGradeWithoutEc + midtermGrade + finalGrade + termProjectGrade;
// Printing the final grades
System.out.println("The final grade without extra credit is: " + finalTotalGradeWithoutEc);
System.out.println("The final grade with extra credit is: " + finalTotalGradeWithEc);
scanner.close(); // Close the scanner
}
}