Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exam_Preparation {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.print("Poor scores limit: ");
- int poorScoreLimit = Integer.parseInt(keyboard.nextLine());
- System.out.print("Task name: ");
- String task = keyboard.nextLine();
- int badScore = 0;
- int sumOfScore = 0;
- int scoreCount = 0;
- String lastTask = "";
- while (!task.equalsIgnoreCase("enough")) {
- int score = Integer.parseInt(keyboard.nextLine());
- sumOfScore+= score;
- scoreCount++;
- if (score < 4) {
- badScore++;
- } if (badScore == poorScoreLimit) {
- System.out.printf("You need a break. You received %d poor scores.", badScore);
- break;
- }
- lastTask = task;
- task = keyboard.nextLine();
- }
- double averageScore = sumOfScore * 1.0 / scoreCount;
- if (task.equalsIgnoreCase("enough")) {
- System.out.printf("Your average score is %.2f.%nYou solved %s tasks.%nThe last task you solved is %s.", averageScore, scoreCount, lastTask);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement