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