remote87

best player

Apr 19th, 2021
594
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         String name = scan.nextLine();
  10.         int goals = 0;
  11.         int maxGoals = 0;
  12.         String bestPlayer = "";
  13.  
  14.         while(!name.equals("END")){
  15.             goals = Integer.parseInt(scan.nextLine());
  16.             if(goals > maxGoals){
  17.                 maxGoals = goals;
  18.                 bestPlayer = name;
  19.             }
  20.             if(goals == 10) name = "END";
  21.             else name = scan.nextLine();
  22.         }
  23.         System.out.println(bestPlayer + " is the best player!");
  24.         if(maxGoals >= 3) System.out.printf("He has scored %d goals and made a hat-trick !!!\n", maxGoals);
  25.         else System.out.printf("He has scored %d goals.", maxGoals);
  26.     }
  27. }
  28.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×