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