Helena12

GameStatistics

Nov 8th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class GameStatistics {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int minutes = Integer.parseInt(scanner.nextLine());
  8.         String playerName = scanner.nextLine();
  9.  
  10.         if (minutes == 0) {
  11.             System.out.println("Match has just began!");
  12.  
  13.         } else if (minutes < 45) {
  14.             System.out.println("First half time.");
  15.         } else {
  16.             System.out.println("Second half time.");
  17.         }
  18.  
  19.         if (minutes >= 1 && minutes <= 10) {
  20.             System.out.printf("%s missed a penalty.\n", playerName);
  21.  
  22.         } else if (minutes > 10 && minutes <= 35) {
  23.             System.out.printf("%s received yellow card.\n", playerName);
  24.  
  25.         } else if (minutes > 35 && minutes < 45) {
  26.             System.out.printf("%s SCORED A GOAL !!!\n", playerName);
  27.  
  28.         } else if (minutes > 45 && minutes <= 55) {
  29.             System.out.printf("%s got a freekick.\n", playerName);
  30.  
  31.         } else if (minutes > 55 && minutes <= 80) {
  32.             System.out.printf("%s missed a shot from corner.\n", playerName);
  33.  
  34.         } else if (minutes > 80 && minutes <= 90) {
  35.             System.out.printf("%s SCORED A GOAL FROM PENALTY !!!\n", playerName);
  36.         }
  37.  
  38.         if (minutes >= 1 && minutes <= 10 && minutes % 2 == 0) {
  39.             System.out.printf("%s was injured after the penalty.", playerName);
  40.  
  41.         } else if (minutes > 10 && minutes <= 35 && minutes % 2 != 0) {
  42.             System.out.printf("%s got another yellow card.", playerName);
  43.  
  44.         } else if (minutes > 45 && minutes <= 55 && minutes % 2 == 0) {
  45.             System.out.printf("%s missed the freekick.", playerName);
  46.  
  47.         } else if (minutes > 55 && minutes <= 80 && minutes % 2 != 0) {
  48.             System.out.printf("%s has been changed with another player.", playerName);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment