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());
- string input = Console.ReadLine();
- int purchasesCount = 0;
- decimal price = 0;
- input = Console.ReadLine();
- while (input != "mall.Exit")
- {
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] >= 65 && input[i] <= 90)
- {
- price = input[i] * 0.5m;
- if (money >= price)
- {
- money -= price;
- purchasesCount++;
- }
- }
- else if (input[i] >= 97 && input[i] <= 122)
- {
- price = input[i] * 0.3m;
- if (money >= price)
- {
- money -= price;
- purchasesCount++;
- }
- }
- else if (input[i] == 37)
- {
- if (money > 0)
- {
- money /= 2;
- purchasesCount++;
- }
- }
- else if (input[i] == 42)
- {
- money += 10;
- }
- else
- {
- price = input[i];
- if (money >= price)
- {
- money -= price;
- purchasesCount++;
- }
- }
- }
- input = Console.ReadLine();
- }
- if (purchasesCount == 0)
- {
- Console.WriteLine($"No purchases. Money left: {money:f2} lv.");
- }
- else
- {
- Console.WriteLine($"{purchasesCount} purchases. Money left: {money:f2} lv.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment