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;
- class PassionDays
- {
- static void Main()
- {
- decimal money = decimal.Parse(Console.ReadLine());
- string enter = Console.ReadLine();
- long purchaseCounter = 0L;
- decimal result = 0;
- while (enter!="mall.Enter")
- {
- if (enter == "mall.Exit")
- {
- break;
- }
- else
- {
- enter = Console.ReadLine();
- continue;
- }
- }
- while (enter != "mall.Exit")
- {
- enter = Console.ReadLine();
- if (enter == "mall.Exit")
- {
- break;
- }
- else
- {
- char[] symbols = new char[enter.Length];
- for (int i = 0; i < enter.Length; i++)
- {
- symbols[i] = enter[i];
- }
- for (int i = 0; i < symbols.Length; i++)
- {
- if (symbols[i] >= 'A' && symbols[i] <= 'Z')
- {
- result = money - symbols[i] / 2M;
- if (result>=0)
- {
- money -= symbols[i] / 2M;
- purchaseCounter++;
- }
- }
- if (symbols[i] >= 'a' && symbols[i] <= 'z')
- {
- var percent = symbols[i] * 0.3M;
- result = money - percent;
- if (result >= 0)
- {
- money -= percent;
- purchaseCounter++;
- }
- }
- if (symbols[i] == '%' )
- {
- result = money /2M;
- if (result >= 0)
- {
- money /= 2M;
- purchaseCounter++;
- }
- }
- if (symbols[i] == '*')
- {
- money += 10;
- }
- }
- }
- }
- if (purchaseCounter==0)
- {
- Console.WriteLine("No purchases. Money left: {0:0.00} lv.",money);
- }
- else
- {
- Console.WriteLine("{0} purchases. Money left: {1:0.00} lv.",purchaseCounter, money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment