-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgradeArray.java
More file actions
29 lines (25 loc) · 912 Bytes
/
gradeArray.java
File metadata and controls
29 lines (25 loc) · 912 Bytes
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
package src;
public class gradeArray {
public static void main(String[] args) {
System.out.println("Grade Distribution : ");
// Array storing stars counts.
int[] array = {0, 0, 0, 0, 0, 0, 1, 2, 4, 2, 1};
// Loop for iterating over the src.array
for (int counter = 0; counter < array.length; counter++) {
// if src.counter is 10 print 100
if (counter == 10) {
System.out.printf("%8d", 100);
}
// else print the 00 - 09 sequence.
else {
System.out.printf("%02d - %02d", (counter * 10), (counter * 10 + 9));
}
// loop for printing the starts
for (int star = 0; star < array[counter]; star++) {
System.out.print("*");
}
// just for line breaking.
System.out.println();
}
}
}