Advertisement
Somo4k

05.FootbalTournament

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