-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurvey.java
More file actions
22 lines (21 loc) · 930 Bytes
/
Survey.java
File metadata and controls
22 lines (21 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class Survey {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String[] scales = {"Awful", "Worse", "Very Poor", "Poor", "Below Average", "Average", "Above Average", "Good", "Very Good", "Excellent"};
int[] num_scale = new int[10];
for (int i = 0; i < num_scale.length; i++) {
System.out.print("Rate the food quality in cafeteria 1-10 : ");
num_scale[i] = input.nextInt();
}
System.out.println("\n--- RESULT of the POLL ---");
for (int i = 0; i < scales.length; i++) {
double count = 0;
for (int j = 0; j < num_scale.length; j++) {
if (num_scale[j] == i + 1) count++;
}
double pcent = (count / num_scale.length) * 100;
System.out.printf("%-15s = %4.0f Percent \n", scales[i], pcent);
}
}
}