Advertisement
jwrbg

fUck

Jan 31st, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. package ProgammingBasics;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class examOnExam {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double numOfstudents = Double.parseDouble(scanner.nextLine());
  9.         int counter = 0;
  10.         int counterFive = 0;
  11.         int counterFour = 0;
  12.         int counterThree = 0;
  13.         int counterTwo = 0;
  14.         double totalGrade = 0;
  15.  
  16.         while (counter < numOfstudents) {
  17.             double gradeOfstudents = Double.parseDouble(scanner.next());
  18.             totalGrade += gradeOfstudents;
  19.             counter++;
  20.             if (gradeOfstudents >= 5) {
  21.                 counterFive++;
  22.             } else if (gradeOfstudents < 5 && gradeOfstudents >= 4) {
  23.                 counterFour++;
  24.             }
  25.             if (gradeOfstudents < 4 && counter >= 3) {
  26.                 counterThree++;
  27.             }
  28.             if (gradeOfstudents < 3) {
  29.                 counterTwo++;
  30.             }
  31.  
  32.         }
  33.  
  34.         System.out.printf("Top students: %.2f%%%n", (counterFive / numOfstudents) * 100);
  35.         System.out.printf("Between 4.00 and 4.99: %.2f%%%n", (counterFour / numOfstudents) * 100);
  36.         System.out.printf("Between 3.00 and 3.99: %.2f%%%n", (counterThree / numOfstudents) * 100);
  37.         System.out.printf("Fail: %.2f%%%n", (counterTwo / numOfstudents) * 100);
  38.         System.out.printf("Average: %.2f", (totalGrade / numOfstudents));
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement