Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PassionDays
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal money = decimal.Parse(Console.ReadLine());
- string input = Console.ReadLine(); //read <enter.Mall> here
- int purchasesCount = 0;
- decimal price = 0;
- //Following not needed => there is no input before <mall.Enter> in the tests:
- //while (input != "mall.Enter")
- //{
- // input = Console.ReadLine(); // or continue;
- //}
- input = Console.ReadLine(); //read first action input here
- 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++;
- }
- //if (money < price) continue;
- //money -= price;
- //purchasesCount++;
- }
- else if (input[i] >= 97 && input[i] <= 122)
- {
- price = input[i] * 0.3m;
- if (money >= price)
- {
- money -= price;
- purchasesCount++;
- }
- //if (money < price) continue;
- //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++;
- }
- //if (money < price) continue;
- //money -= price;
- //purchasesCount++;
- }
- }
- input = Console.ReadLine(); //read all other action inputs or <mall.Exit> here
- }
- 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
Advertisement