Advertisement
dinko_dt

Untitled

Nov 25th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4. using System.Linq;
  5.  
  6.  
  7. namespace Football_Tournament
  8. {
  9. class FootballTournament
  10. {
  11. static void Main()
  12. {
  13. string teamName = Console.ReadLine();
  14. int playedGames = int.Parse(Console.ReadLine());
  15.  
  16. int wonGames = 0;
  17. int drawGames = 0;
  18. int lostGames = 0;
  19.  
  20. if (playedGames > 0)
  21. {
  22. for (int i = 1; i <= playedGames; i++)
  23. {
  24. string gameResult = Console.ReadLine();
  25. if (gameResult == "W") wonGames++;
  26. else if (gameResult == "D") drawGames++;
  27. else if (gameResult == "L") lostGames++;
  28. }
  29. int totalWonPoints = wonGames * 3 + drawGames;
  30. Console.WriteLine($"{teamName} has won {totalWonPoints} points during this season.");
  31. Console.WriteLine("Total stats:");
  32. Console.WriteLine($"## W: {wonGames}");
  33. Console.WriteLine($"## D: {drawGames}");
  34. Console.WriteLine($"## L: {lostGames}");
  35. Console.WriteLine($"Win rate: {wonGames / (playedGames * 0.01):F2}%");
  36. }
  37. else
  38. {
  39. Console.WriteLine($"{teamName} hasn't played any games during this season.");
  40. }
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement