Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- int playerOne = int.Parse(Console.ReadLine());
- int playerTwo = int.Parse(Console.ReadLine());
- string command = Console.ReadLine();
- while (command != "End of battle")
- {
- if (command == "one")
- {
- playerTwo--;
- }
- else
- {
- playerOne--;
- }
- if (playerOne == 0)
- {
- Console.WriteLine($"Player one is out of eggs. Player two has {playerTwo} eggs left.");
- break;
- }
- if (playerTwo == 0)
- {
- Console.WriteLine($"Player two is out of eggs. Player one has {playerOne} eggs left.");
- break;
- }
- command = Console.ReadLine();
- }
- if (command == "End of battle")
- {
- Console.WriteLine($"Player one has {playerOne} eggs left.");
- Console.WriteLine($"Player two has {playerTwo} eggs left.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment