Advertisement
Valantina

FootballTournament/Exam

Jul 9th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P05_FootballTournament
  4. {
  5.     class P05_FootballTournament
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string teamName = Console.ReadLine();
  10.             int gamesCount = int.Parse(Console.ReadLine());
  11.  
  12.             int totalPoints = 0;
  13.  
  14.             int totalWins = 0;
  15.             int totalDraws = 0;
  16.  
  17.             for (int i = 0; i < gamesCount; i++)
  18.             {
  19.                 string gameType = Console.ReadLine();
  20.  
  21.                 if ("W" == gameType)
  22.                 {
  23.                     totalPoints += 3;
  24.                     totalWins++;
  25.                 }
  26.                 else if ("D" == gameType)
  27.                 {
  28.                     totalPoints += 1;
  29.                     totalDraws++;
  30.                 }
  31.             }
  32.  
  33.             if (gamesCount == 0)
  34.             {
  35.                 Console.WriteLine($"{teamName} hasn't played any games during this season.");
  36.             }
  37.             else
  38.             {
  39.                 double winRate = totalWins * 1.0 / gamesCount * 100;
  40.  
  41.                 Console.WriteLine($"{teamName} has won {totalPoints} points during this season.");
  42.                 Console.WriteLine("Total stats:");
  43.                 Console.WriteLine($"## W: {totalWins}");
  44.                 Console.WriteLine($"## D: {totalDraws}");
  45.                 Console.WriteLine($"## L: {gamesCount - totalWins - totalDraws}");
  46.                 Console.WriteLine($"Win rate: {winRate:F2}%");
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement