Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _01.PassionDays
- {
- class PassionDays
- {
- static void Main(string[] args)
- {
- decimal money = decimal.Parse(Console.ReadLine());
- int countPurchases = 0;
- string command = "";
- do {command = Console.ReadLine(); } while (command != "mall.Enter");
- while (true)
- {
- command = Console.ReadLine();
- if (command == "mall.Exit")
- {
- break;
- }
- foreach (char action in command)
- {
- if (action == '*')
- {
- money += 10;
- continue;
- }
- decimal price = 0;
- if (char.IsLetter(action) && char.IsUpper(action))
- {
- price = 0.5m * (int)action;
- }
- else if (char.IsLetter(action) && char.IsLower(action))
- {
- price = 0.3m * (int)action;
- }
- else if (action == '%')
- {
- price = money / 2;
- }
- else
- {
- price = (int)action;
- }
- if (money < price || money == 0)
- {
- continue;
- }
- money -= price;
- countPurchases++;
- }
- }
- string purchases = countPurchases == 0 ? "No" : countPurchases.ToString();
- Console.WriteLine($"{purchases} purchases. Money left: {money:f2} lv.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment