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)
- {
- // A = 50%
- // a = 70%
- // % = /50
- // * = +10lv
- decimal moneyStart = decimal.Parse(Console.ReadLine());
- string line = Console.ReadLine();
- int puchases = 0;
- while (line != "mall.Enter")
- {
- line = Console.ReadLine();
- }
- line = Console.ReadLine();
- while (line != "mall.Exit")
- {
- string actions = line;
- for (int i = 0; i < actions.Length; i++)
- {
- decimal price = 0;
- if (actions[i] >= 65 && actions[i] <= 90)
- {
- price = actions[i] * 0.5m;
- if (moneyStart < price)
- {
- break;
- }
- moneyStart -= price;
- puchases++;
- }
- else if (actions[i] >= 97 && actions[i] <= 122)
- {
- price = actions[i] * 0.3m;
- if (moneyStart < price)
- {
- break;
- }
- moneyStart -= price;
- puchases++;
- }
- else if (actions[i] == '%')
- {
- moneyStart /= 2;
- puchases++;
- }
- else if (actions[i] == '*')
- {
- moneyStart += 10;
- }
- else
- {
- moneyStart -= price;
- puchases++;
- }
- }
- line = Console.ReadLine();
- }
- if (puchases == 0)
- {
- Console.WriteLine("No purchases. Money left: {0:f2} lv.", moneyStart);
- }
- else
- {
- Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", puchases, moneyStart);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment