-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrades.java
More file actions
143 lines (113 loc) · 3.73 KB
/
Copy pathGrades.java
File metadata and controls
143 lines (113 loc) · 3.73 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import java.util.*;
public class Grades
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print("Homework Weight? ");
int homeworkWeight = scan.nextInt();
System.out.print("Exam 1 weight? ");
int examOneWeight = scan.nextInt();
int examTwoWeight = homeworkWeight - examOneWeight;
System.out.println("Using Weights of " + homeworkWeight + " " + examOneWeight + " " + examTwoWeight);
System.out.println("Homework: ");
System.out.print("Number of assignments? ");
int assignNumber = scan.nextInt();
System.out.print("Average Homework grade? ");
double aveHomeworkGrade = scan.nextDouble();
System.out.print("Number of late days used? ");
int lateDays = scan.nextInt();
System.out.print("Labs attended? ");
int labAttend = scan.nextInt();
double homeworkPoints = weightedHomeworkScore(homeworkWeight, assignNumber, aveHomeworkGrade, labAttend);
System.out.print("Weighted Score = " + String.format("%.2f", homeworkPoints) + "\n");
System.out.println("Exam One: ");
System.out.println("Score? ");
int examOneScore = scan.nextInt();
System.out.print("Curve? ");
int curveOne = scan.nextInt();
int totalScoreOne = examOneScore + curveOne;
if(totalScoreOne > 100)
{
totalScoreOne = 100;
}
double examOnePoints = weightedExamOneScore(totalScoreOne, examOneWeight, curveOne);
System.out.println("Total Points = " + totalScoreOne + " / 100");
System.out.print("Weighted Score = " + examOnePoints + "\n");
System.out.println("Exam Two: ");
System.out.println("Score? ");
int examTwoScore = scan.nextInt();
System.out.print("Curve? ");
int curveTwo = scan.nextInt();
int totalScoreTwo = examTwoScore + curveTwo;
if(totalScoreTwo > 100)
{
totalScoreTwo = 100;
}
double examTwoPoints = weightedExamTwoScore(totalScoreTwo, examTwoWeight, curveTwo);
System.out.println("Total Points = " + totalScoreTwo + " / 100");
System.out.print("Weighted Score = " + examTwoPoints + "\n");
//Adds points if the student has 0 late days
if(lateDays == 0)
{
homeworkPoints += 5;
if(homeworkPoints > 100)
{
homeworkPoints = 100;
}
}
double grade = courseGrade(homeworkPoints, examOnePoints, examTwoPoints);
//deducts points if student has more late days than half of the assignments
if(assignNumber / 2 < lateDays)
{
double deduct = grade / 10.0;
grade = grade - deduct;
}
System.out.println("Course grade = " + String.format("%.2f", grade));
}
public static double weightedHomeworkScore(double weight, double assignNum, double aveHW, double labPresent)
{
double homeworkScore = weight * (aveHW * assignNum + labPresent * 4) / (10 * 10 + 4 * 10);
return homeworkScore;
}
public static double weightedExamOneScore(double examScore, double weight, double curve)
{
double examOnePoints = 0.0;
if(curve >= 0)
{
examOnePoints = weight * examScore / 100;
}
else
{
examScore += curve;
if(examScore > 100)
{
examScore = 100;
}
examOnePoints = weight * examScore / 100;
}
return examOnePoints;
}
public static double weightedExamTwoScore(double examScore, double weight, double curve)
{
double examTwoPoints = 0.0;
if(curve >= 0)
{
examTwoPoints = weight * examScore / 100;
}
else
{
examScore += curve;
if(examScore > 100)
{
examScore = 100;
}
examTwoPoints = weight * examScore / 100;
}
return examTwoPoints;
}
public static double courseGrade(double homeworkGrade, double examOneGrade, double examTwoGrade)
{
return homeworkGrade + examOneGrade + examTwoGrade;
}
}