Advertisement
Guest User

Untitled

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