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 Passion_Days
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal startMoney = decimal.Parse(Console.ReadLine());
- string mallAction = Console.ReadLine();
- decimal price = 0.0m;
- char[] symbol = new char[20];
- int purchaseCounter = 0;
- while (mallAction != "mall.Enter")
- {
- mallAction = Console.ReadLine();
- }
- while (mallAction != "mall.Exit")
- {
- mallAction = Console.ReadLine();
- if (mallAction=="mall.Exit")
- {
- break;
- }
- symbol = mallAction.ToCharArray();
- for (int i = 0; i < symbol.Length; i++)
- {
- if (char.IsLetter(symbol[i]) && char.IsUpper(symbol[i]))
- {
- price = symbol[i];
- price *= 0.5m;
- if (price > startMoney)
- {
- continue;
- }
- startMoney -= price;
- purchaseCounter++;
- }
- else if (char.IsLetter(symbol[i]) && char.IsLower(symbol[i]))
- {
- price = symbol[i];
- price *= 0.3m;
- if (price > startMoney)
- {
- continue;
- }
- startMoney -= price;
- purchaseCounter++;
- }
- else if (symbol[i] == '%')
- {
- if (startMoney<=0)
- {
- continue;
- }
- startMoney /= 2;
- purchaseCounter++;
- }
- else if (symbol[i] == '*')
- {
- startMoney += 10;
- }
- else
- {
- price = symbol[i];
- if (price > startMoney)
- {
- continue;
- }
- startMoney -= price;
- purchaseCounter++;
- }
- }
- }
- if (purchaseCounter==0)
- {
- Console.WriteLine("No purchases. Money left: {0:f2} lv.", startMoney);
- }
- else
- {
- Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", purchaseCounter, startMoney);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment