Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- int startMoney = int.Parse(Console.ReadLine());
- string command = Console.ReadLine();
- int clothesCounter =0;
- int moneyLeft =startMoney;
- int spentMoney=0;
- while (true) // while (spentMoney<=startMoney)
- {
- if (command == "enter")
- {
- command = Console.ReadLine();
- while (command != "leave")
- {
- int currSpentMoney = int.Parse(command);
- if (currSpentMoney > moneyLeft)
- {
- Console.WriteLine("Not enough money.");
- }
- else
- {
- moneyLeft -= currSpentMoney;
- spentMoney += currSpentMoney;
- clothesCounter ++;
- if (spentMoney >= startMoney)
- {
- Console.WriteLine("For {0} clothes I spent {1} lv and have {2} lv left.",clothesCounter,spentMoney,moneyLeft);
- return;
- }
- }
- command = Console.ReadLine();
- }
- if (command == "leave")
- {
- command = Console.ReadLine();
- {
- while (command!= "enter")
- {
- if (command == "enough")
- {
- Console.WriteLine("For {0} clothes I spent {1} lv and have {2} lv left.",clothesCounter,spentMoney,moneyLeft);
- return;
- }
- command = Console.ReadLine();
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement