Guest User

Untitled

a guest
Nov 29th, 2019
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BasketballTournament
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string nameOfTournament = Console.ReadLine();
  10. int winCounter = 0;
  11. int loseCounter = 0;
  12. int totalMatches = 0;
  13. while (nameOfTournament != "End of tournaments")
  14. {
  15. int NumberOfMatches = int.Parse(Console.ReadLine());
  16. totalMatches+= NumberOfMatches;
  17. for (int i = 1; i <= NumberOfMatches; i++)
  18. {
  19. int myPoints = int.Parse(Console.ReadLine());
  20. int enemyPoints = int.Parse(Console.ReadLine());
  21.  
  22. if(myPoints > enemyPoints)
  23. {
  24. winCounter+=1;
  25. int diff = myPoints - enemyPoints;
  26. Console.WriteLine($"Game {i} of tournament {nameOfTournament}: win with {diff} points.");
  27.  
  28. }
  29. else if(myPoints < enemyPoints)
  30. {
  31. loseCounter+=1;
  32. int diff = enemyPoints - myPoints;
  33. Console.WriteLine($"Game {i} of tournament {nameOfTournament}: lost with {diff} points.");
  34.  
  35. }
  36. }
  37.  
  38. nameOfTournament = Console.ReadLine();
  39.  
  40. }
  41. int winPercent = (winCounter / totalMatches) * 100;
  42. int losePercent = (loseCounter / totalMatches) * 100;
  43. Console.WriteLine($"{winPercent:f2}% matches win");
  44. Console.WriteLine($"{losePercent:f2}% matches lost");
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment