Guest User

Untitled

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