Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgammingBasics;
- import java.util.Scanner;
- public class examOnExam {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double numOfstudents = Double.parseDouble(scanner.nextLine());
- int counter = 0;
- int counterFive = 0;
- int counterFour = 0;
- int counterThree = 0;
- int counterTwo = 0;
- double totalGrade = 0;
- while (counter < numOfstudents) {
- double gradeOfstudents = Double.parseDouble(scanner.next());
- totalGrade += gradeOfstudents;
- counter++;
- if (gradeOfstudents >= 5) {
- counterFive++;
- } else if (gradeOfstudents < 5 && gradeOfstudents >= 4) {
- counterFour++;
- }
- if (gradeOfstudents < 4 && counter >= 3) {
- counterThree++;
- }
- if (gradeOfstudents < 3) {
- counterTwo++;
- }
- }
- System.out.printf("Top students: %.2f%%%n", (counterFive / numOfstudents) * 100);
- System.out.printf("Between 4.00 and 4.99: %.2f%%%n", (counterFour / numOfstudents) * 100);
- System.out.printf("Between 3.00 and 3.99: %.2f%%%n", (counterThree / numOfstudents) * 100);
- System.out.printf("Fail: %.2f%%%n", (counterTwo / numOfstudents) * 100);
- System.out.printf("Average: %.2f", (totalGrade / numOfstudents));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement