Advertisement
silvana1303

tournament of christmas

May 2nd, 2020
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int tournaments = int.Parse(Console.ReadLine());
  10.             double totalCharity = 0.0;
  11.             int totalWin = 0;
  12.             int totalLoses = 0;
  13.  
  14.             for (int i = 0; i < tournaments; i++)
  15.             {
  16.                 int winCount = 0;
  17.                 int loseCount = 0;
  18.                 double charity = 0.0;
  19.                 string sport = Console.ReadLine();
  20.                
  21.                 while (sport != "Finish")
  22.                 {
  23.                     string command = Console.ReadLine();
  24.  
  25.                     if (command == "win")
  26.                     {
  27.                         charity += 20;
  28.                         winCount++;
  29.                         totalWin++;
  30.                     }
  31.                     else
  32.                     {
  33.                         loseCount++;
  34.                         totalLoses++;
  35.                     }
  36.  
  37.                    sport = Console.ReadLine();
  38.                 }
  39.  
  40.                 if (winCount > loseCount)
  41.                 {
  42.                     charity *= 1.10;
  43.                 }
  44.  
  45.                 totalCharity += charity;
  46.             }
  47.  
  48.             if (totalWin > totalLoses)
  49.             {
  50.                 totalCharity *= 1.20;
  51.                 Console.WriteLine($"You won the tournament! Total raised money: {totalCharity:f2}");
  52.             }
  53.             else
  54.             {
  55.                 Console.WriteLine($"You lost the tournament! Total raised money: {totalCharity:f2}");
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement