Advertisement
AntoniiaG

Untitled

Oct 24th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. package Exam;
  2.  
  3. import javafx.scene.control.skin.CellSkinBase;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class ex5 {
  8.     public static void main(String[] args) {
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         String name = scanner.nextLine();
  12.         int goals = Integer.parseInt(scanner.nextLine());
  13.         int max = Integer.MIN_VALUE;
  14.  
  15.         while (!name.equals("END")){
  16.             name = scanner.nextLine();
  17.             goals = Integer.parseInt(scanner.nextLine());
  18.  
  19.             if(goals > max) {
  20.                 max = goals;
  21.  
  22.              if(goals < 3){
  23.                  System.out.printf("%s is the best player!\n", name);
  24.                  System.out.printf("He has scored %d goals.\n", max);
  25.             } else if(goals >= 3 && goals >= 10){
  26.                     System.out.printf("%s is the best player!\n", name);
  27.                     System.out.printf("He has scored %d goals and made a hat-trick !!!\n", max);
  28.                     break;
  29.                }
  30.             }
  31.         }
  32.  
  33.         //На конзолата да се отпечатат 2 реда :
  34.         //•   На първия ред:
  35.         // "{име на играч} is the best player!"
  36.         //•   На втория ред :
  37.         //o  Ако най-добрият футболист е направил хет-трик:
  38.         //  "He has scored {брой голове} goals and made a hat-trick !!!"
  39.         //o Ако най-добрият футболист НЕ е направил хет-трик:
  40.         // "He has scored {брой голове} goals."
  41.  
  42.  
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement