-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrades.java
More file actions
71 lines (62 loc) · 1.76 KB
/
Grades.java
File metadata and controls
71 lines (62 loc) · 1.76 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
//Luke Bradaric
import java.util.Scanner;
public class Grades
{
Scanner sc = new Scanner(System.in);
float total = 0;
int totalGrds;
int f;
public Grades()
{
}
public void newGrades(){
System.out.println("Input Grades, when done type o");
char grade = sc.next().charAt(0);
addGrade(grade);
}
private void addGrade(char grade){
if(grade == 'a'){
total+=4;
totalGrds++;
newGrades();
}else if(grade == 'b'){
total+=3;
totalGrds++;
newGrades();
}else if(grade == 'c'){
total+=2;
totalGrds++;
newGrades();
}else if(grade == 'd'){
total+=1;
totalGrds++;
newGrades();
}
else if(grade == 'f'){
totalGrds++;
f++;
newGrades();
}
else if(grade == 'o'){
printOut();
}
else
System.out.println("Invalid Grade");
}
private void printOut(){
float gpa = total / totalGrds;
if(totalGrds < 4){
System.out.println("Ineligible, taking less than 4 classes");
}else if(gpa < 2.0){
System.out.println("Ineligible, gpa below 2.0");
}else if(gpa >= 2.0 && f > 0){
System.out.println("Ineligible, gpa above 2.0, but has F grade");
}else if(gpa < 2.0 && f > 0){
System.out.println("Ineligible, gpa below 2.0 and has F grade");
}else{
System.out.print("GPA : ");
System.out.printf("%.2f", gpa);
System.out.println(" Eligible");
}
}
}