Guest User

Untitled

a guest
Oct 12th, 2018
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class zadacha3 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int poorGradeLimit = Integer.parseInt(scanner.nextLine());
  8. int poorGradeCount = 0;
  9. int problemCount = 0;
  10. double gradesSum = 0;
  11. String lastProblemName = "";
  12. String problemName = scanner.nextLine();
  13.  
  14. while (poorGradeCount < poorGradeLimit && !problemName.equals("Enough")){
  15. double grade = Double.parseDouble(scanner.nextLine());
  16. problemName = scanner.nextLine();
  17. gradesSum += grade;
  18. lastProblemName = problemName;
  19. problemCount++;
  20.  
  21. if (grade <= 4){
  22. poorGradeCount++;
  23. }
  24. }
  25. if (poorGradeCount < poorGradeLimit){
  26. System.out.printf("Average score: %.2f%n", gradesSum / problemCount);
  27. System.out.printf("Number of problems: %d%n", problemCount);
  28. System.out.printf("Last problem: %s%n", lastProblemName);
  29. }else {
  30. System.out.printf("You need a break, %d poor grades.", poorGradeCount);
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment