Advertisement
Spocoman

Best Player

Dec 9th, 2021 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BestPlayer
  4. {
  5.     class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             string bestPlayer = "";
  10.             int playerGoals = 0;
  11.  
  12.             string command = Console.ReadLine();
  13.  
  14.             while (command != "END" && playerGoals < 10)
  15.             {
  16.                 string currentPlayer = command;
  17.                 int currentGoals = int.Parse(Console.ReadLine());
  18.                 if (currentGoals > playerGoals)
  19.                 {
  20.                     bestPlayer = currentPlayer;
  21.                     playerGoals = currentGoals;
  22.                 }
  23.      
  24.                 command = Console.ReadLine();
  25.             }
  26.             Console.WriteLine($"{bestPlayer} is the best player!");
  27.             if (playerGoals < 3)
  28.             {
  29.                 Console.WriteLine($"He has scored {playerGoals} goals.");
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine($"He has scored {playerGoals} goals and made a hat-trick !!!");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement