Advertisement
desislava_topuzakova

05. Darts Tournament

May 1st, 2020
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. namespace demo
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             int startPoints = int.Parse(Console.ReadLine());
  12.             int count = 0;
  13.            
  14.             while (startPoints > 0)
  15.             {
  16.                 string sector = Console.ReadLine();
  17.                
  18.                 count++;
  19.  
  20.                 //"number section", "double ring",
  21.                 //"triple ring", "bullseye"
  22.                 if (sector == "number section")
  23.                 {
  24.                     int pointsFromSector = int.Parse(Console.ReadLine());
  25.                     startPoints -= pointsFromSector;
  26.                 }
  27.                 else if (sector == "double ring")
  28.                 {
  29.                     int pointsFromSector = int.Parse(Console.ReadLine());
  30.                     startPoints -= pointsFromSector * 2;
  31.                 }
  32.                 else if (sector == "triple ring")
  33.                 {
  34.                     int pointsFromSector = int.Parse(Console.ReadLine());
  35.                     startPoints -= pointsFromSector * 3;
  36.                 }
  37.                 else if (sector == "bullseye")
  38.                 {
  39.                     Console.WriteLine($"Congratulations! You won the game with a bullseye in {count} moves!");
  40.                     break;
  41.                 }
  42.  
  43.                 if (startPoints < 0)
  44.                 {
  45.                     Console.WriteLine($"Sorry, you lost. Score difference: {Math.Abs(startPoints)}.");
  46.                     break;
  47.                 }
  48.  
  49.             }
  50.  
  51.             if (startPoints == 0)
  52.             {
  53.                 Console.WriteLine($"Congratulations! You won the game in {count} moves!");
  54.             }
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement