Advertisement
silvana1303

football tournament

Apr 29th, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4.  
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string team = Console.ReadLine();
  11.             int gamesCount = int.Parse(Console.ReadLine());
  12.             string endGame = Console.ReadLine();
  13.             int winCount = 0;
  14.             int drawCount = 0;
  15.             int loseCount = 0;
  16.  
  17.             if (gamesCount == 0)
  18.             {
  19.                 Console.WriteLine($"{team} hasn't played any games during this season.");
  20.                 return;
  21.             }
  22.            
  23.  
  24.             for (int i = 0; i < gamesCount; i++)
  25.             {
  26.                 char game = char.Parse(endGame);
  27.  
  28.  
  29.                 if (game == 'W')
  30.                 {
  31.                     winCount++;
  32.  
  33.                 }
  34.                 else if (game == 'D')
  35.                 {
  36.                     drawCount++;
  37.                 }
  38.                 else
  39.                 {
  40.                     loseCount++;
  41.                 }
  42.  
  43.                 endGame = Console.ReadLine();
  44.             }
  45.  
  46.             int pointsWin = winCount * 3;
  47.             int pointsDraw = drawCount * 1;
  48.             int fullpoints = pointsWin + pointsDraw;
  49.             double percentWin = winCount * 1.0 / gamesCount * 100.0;
  50.  
  51.             Console.WriteLine($"{team} has won {fullpoints} points during this season.");
  52.             Console.WriteLine("Total stats:");
  53.             Console.WriteLine($"## W: {winCount}");
  54.             Console.WriteLine($"## D: {drawCount}");
  55.             Console.WriteLine($"## L: {loseCount}");
  56.             Console.WriteLine($"Win rate: {percentWin:f2}%");
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement