Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04.Darts
- {
- class Darts
- {
- static void Main(string[] args)
- {
- string name = Console.ReadLine();
- int leftPoints = 301;
- int removed = 0;
- int counter = 0;
- int failCounter = 0;
- while (true)
- {
- string field = Console.ReadLine();
- if(field == "Retire")
- {
- Console.WriteLine($"{name} retired after {failCounter} unsuccessful shots.");
- break;
- }
- int points = int.Parse(Console.ReadLine());
- if (field == "Single")
- {
- removed = points;
- counter++;
- }
- else if (field == "Double")
- {
- removed = (points * 2);
- counter++;
- }
- else if (field == "Triple")
- {
- removed = (points * 3);
- counter++;
- }
- if (leftPoints < removed)
- {
- failCounter++;
- continue;
- }
- if (leftPoints == removed)
- {
- Console.WriteLine($"{name} won the leg with {counter-failCounter} shots.");
- break;
- }
- leftPoints = leftPoints - removed;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment