Advertisement
sanyakasarova

05. Darts

Dec 11th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. string name = Console.ReadLine();
  9.  
  10. int points = 301;
  11. int successfulShots = 0;
  12. int unsuccessfulShots = 0;
  13.  
  14. string sector = Console.ReadLine();
  15. while (sector != "Retire")
  16. {
  17. int currentPoints = int.Parse(Console.ReadLine());
  18.  
  19. int totalCurrentPoints = 0;
  20.  
  21. if (sector == "Single")
  22. {
  23. totalCurrentPoints = currentPoints;
  24. }
  25. else if (sector == "Double")
  26. {
  27. totalCurrentPoints = currentPoints * 2;
  28. }
  29. else if (sector == "Triple")
  30. {
  31. totalCurrentPoints = currentPoints * 3;
  32. }
  33.  
  34. if (points >= totalCurrentPoints)
  35. {
  36. points -= totalCurrentPoints;
  37. successfulShots++;
  38. }
  39. else
  40. {
  41. unsuccessfulShots++;
  42. }
  43.  
  44. if (points == 0)
  45. {
  46. Console.WriteLine($"{name} won the leg with {successfulShots} shots.");
  47. break;
  48. }
  49.  
  50. sector = Console.ReadLine();
  51. }
  52.  
  53. if (points != 0)
  54. {
  55. Console.WriteLine($"{name} retired after {unsuccessfulShots} unsuccessful shots.");
  56. }
  57.  
  58.  
  59. }
  60.  
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement