-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradingSummary.java
More file actions
38 lines (29 loc) · 1.1 KB
/
Copy pathGradingSummary.java
File metadata and controls
38 lines (29 loc) · 1.1 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
import java.util.Scanner;
public class GradingSummary {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int [] gradeCount = new int[10]; // index 1-9 used
int count = 1;
while (count <= 5){
System.out.print("Enter score for student "+count+": ");
int score = input.nextInt();
int grade = 0;
if(score >= 80 && score <= 100) grade = 1;
else if (score >= 75) grade = 2;
else if (score >= 66) grade = 3;
else if (score >= 60) grade = 4;
else if (score >= 50) grade = 5;
else if (score >= 45) grade = 6;
else if (score >= 35) grade = 7;
else if (score >= 30) grade = 8;
else grade = 9;
gradeCount[grade]++;
count++;
}
System.out.println("\n ------Grade Summary -------");
for(int i = 1; i <= 9; i++){
System.out.println("Grade "+i+": "+gradeCount[i]+" student(s).");
}
input.close();
}
}