Advertisement
Grimmjow1

Darts

Mar 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Fourth
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string name = Console.ReadLine();
  14.             int goal = 301;
  15.             int scored = 0;
  16.             int notScored = 0;
  17.            
  18.             while (true)
  19.             {
  20.                 string imput = Console.ReadLine();
  21.                 if (imput== "Retire")
  22.                 {
  23.                     break;
  24.                 }
  25.                 int points = int.Parse(Console.ReadLine());
  26.                 if (imput== "Single")
  27.                 {
  28.                     points = points * 1;
  29.                 }
  30.                 else if (imput== "Double")
  31.                 {
  32.                     points = points * 2;
  33.                 }
  34.                 else if (imput=="Triple")
  35.                 {
  36.                     points = points * 3;
  37.                 }
  38.                
  39.                 if ( points<=goal)
  40.                 {
  41.                     scored++;
  42.                     goal = goal - points;
  43.  
  44.                 }
  45.                 else
  46.                 {
  47.  
  48.                     notScored++;
  49.                 }
  50.                 if (goal==0)
  51.                 {
  52.                     Console.WriteLine("{0} won the leg with {1} shots.", name, scored);
  53.                     return;
  54.                 }
  55.                
  56.             }
  57.             Console.WriteLine("{0} retired after {1} unsuccessful shots.",name,notScored);
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement