Advertisement
Yanislav29

Untitled

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