NewInCSharp

Untitled

Nov 28th, 2019
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Darts
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string name = Console.ReadLine();
  10.  
  11. double score = 301;
  12. double successfulShots = 0;
  13. double unsuccessfulShots = 0;
  14.  
  15. string type = Console.ReadLine();
  16. while (type != "Retire")
  17. {
  18.  
  19.  
  20. int points = int.Parse(Console.ReadLine());
  21.  
  22. if (type == "Single")
  23. {
  24. score -= points;
  25. if (score >= 0)
  26. {
  27. successfulShots++;
  28. }
  29. else
  30. {
  31. unsuccessfulShots++;
  32. score += points;
  33. }
  34. }
  35. else if (type == "Double")
  36. {
  37. score -= points * 2;
  38. if (score >= 0)
  39. {
  40. successfulShots++;
  41. }
  42. else
  43. {
  44. unsuccessfulShots++;
  45. score += points * 2;
  46. }
  47. }
  48. else if (type == "Triple")
  49. {
  50. score -= points * 3;
  51. if (score >= 0)
  52. {
  53. successfulShots++;
  54. }
  55. else
  56. {
  57. unsuccessfulShots++;
  58. score += points * 3;
  59. }
  60. }
  61.  
  62. if (score == 0)
  63. {
  64. Console.WriteLine($"{name} won the leg with {successfulShots} shots.");
  65. break;
  66. }
  67.  
  68.  
  69. type = Console.ReadLine();
  70. }
  71.  
  72. if (type == "Retire")
  73. {
  74. Console.WriteLine($"{name} retired after {unsuccessfulShots} unsuccessful shots.");
  75. }
  76. }
  77.  
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment