Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int studentCount = scanner.nextInt();
- double examMark = 0;
- int topStudents = 0;
- int students4and5 = 0;
- int students3and4 = 0;
- int failedStudents = 0;
- double allMarksSum = 0.0;
- for (int i = 1; i <= studentCount; i++) {
- examMark = scanner.nextDouble();
- if (examMark >= 5.00) {
- topStudents++;
- }
- if (examMark >= 4.00 && examMark <= 4.99) {
- students4and5++;
- }
- if (examMark >= 3.00 && examMark <= 3.99) {
- students3and4++;
- }
- if (examMark < 3.00) {
- failedStudents++;
- }
- allMarksSum += examMark;
- }
- System.out.printf("Top students: %.2f%%\n",(double)topStudents/studentCount * 100);
- System.out.printf("Between 4.00 and 4.99: %.2f%%\n",(double)students4and5/studentCount * 100);
- System.out.printf("Between 3.00 and 3.99: %.2f%%\n",(double)students3and4/studentCount * 100);
- System.out.printf("Fail: %.2f%%\n",(double)failedStudents/studentCount * 100);
- System.out.printf("Average: %.2f",(double)allMarksSum/studentCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement