Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExamPreparation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int lowGradesLimit= Integer.parseInt(scanner.nextLine());
- int failedCount = 0;
- int gradesCount = 0;
- double ratioSum= 0;
- String lastExam = "";
- boolean tired = false;
- while (failedCount<lowGradesLimit){
- String examName = scanner.nextLine();
- if ("Enough".equals(examName)){
- tired = true;
- break;
- }
- int examScore = Integer.parseInt(scanner.nextLine());
- if(examScore <=4){
- failedCount++;
- }
- ratioSum+=examScore;
- gradesCount++;
- lastExam=examName;
- }
- double ratioSumTotal = ratioSum /gradesCount;
- if(!tired){
- System.out.printf("You need a break, %d poor grades.",lowGradesLimit);
- }else{
- System.out.printf("Average score: %.2f%n",ratioSumTotal);
- System.out.printf("Number of problems: %d%n",gradesCount);
- System.out.printf("Last problem: %s",lastExam);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement