Advertisement
silvana1303

darts tournament

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