Advertisement
Yanislav29

Untitled

Nov 27th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace ConsoleApp6
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string playerName = Console.ReadLine();
  11. int gamesCount = int.Parse(Console.ReadLine());
  12. int volleyCnt = 0, tenisCnt = 0, badmCnt = 0;
  13. double volleyScore = 0.0;
  14. double tennisScore = 0.0;
  15. double badminScore = 0.0;
  16. for(int i = 0; i < gamesCount; i++)
  17. {
  18. string gameName = Console.ReadLine();
  19. int points = int.Parse(Console.ReadLine());
  20.  
  21. if(gameName == "volleyball")
  22. {
  23. volleyScore += points + (0.07 * points);
  24. volleyCnt++;
  25. }
  26. else if(gameName == "tennis")
  27. {
  28. tennisScore += points + (0.05 * points);
  29. tenisCnt++;
  30. }
  31. else if (gameName == "badminton")
  32. {
  33. badminScore += points + (0.02 * points);
  34. badmCnt++;
  35. }
  36.  
  37. }
  38. double avg = 0;
  39. double total = Math.Floor(volleyScore + tennisScore + badminScore);
  40. avg = Math.Floor(total / (badmCnt + volleyCnt + tenisCnt));
  41. if(avg >= 75)
  42. {
  43. Console.WriteLine($"Congratulations, {playerName}! You won the cruise games with {total} points.");
  44. }
  45. else
  46. {
  47. Console.WriteLine($"Sorry, {playerName}, you lost. Your points are only {total}.");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement