Advertisement
Kancho

Exam_Prepaaration

Feb 6th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exam_Preparation {
  4. public static void main(String[] args) {
  5. Scanner keyboard = new Scanner(System.in);
  6. System.out.print("Poor scores limit: ");
  7. int poorScoreLimit = Integer.parseInt(keyboard.nextLine());
  8. System.out.print("Task name: ");
  9. String task = keyboard.nextLine();
  10. int badScore = 0;
  11. int sumOfScore = 0;
  12. int scoreCount = 0;
  13. String lastTask = "";
  14. while (!task.equalsIgnoreCase("enough")) {
  15.  
  16. int score = Integer.parseInt(keyboard.nextLine());
  17. sumOfScore+= score;
  18. scoreCount++;
  19. if (score < 4) {
  20. badScore++;
  21. } if (badScore == poorScoreLimit) {
  22. System.out.printf("You need a break. You received %d poor scores.", badScore);
  23. break;
  24. }
  25. lastTask = task;
  26. task = keyboard.nextLine();
  27.  
  28. }
  29. double averageScore = sumOfScore * 1.0 / scoreCount;
  30. if (task.equalsIgnoreCase("enough")) {
  31. System.out.printf("Your average score is %.2f.%nYou solved %s tasks.%nThe last task you solved is %s.", averageScore, scoreCount, lastTask);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement