Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Practice
- {
- static void Main()
- {
- decimal money = decimal.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- //wait for "mall.Enter" input
- while (input!="mall.Enter")
- {
- input = Console.ReadLine();
- }
- input = Console.ReadLine();
- decimal price = 0;
- decimal currentItem = 0; int orders = 0;
- //wait for "mall.Exit" input
- while (input!="mall.Exit")
- {
- for (int i = 0; i < input.Length; i++)
- {
- currentItem = input[i];
- if (input[i]>='A'&&input[i]<='Z')
- {
- price = currentItem * 0.5m;
- }
- else if (input[i]>='a'&&input[i]<='z')
- {
- price = currentItem * 0.3m;
- }
- else if (input[i]=='%')
- {
- if (money > 0)
- {
- money /= 2; orders++;
- }
- }
- else if (input[i]=='*')
- {
- money += 10;
- }
- else { price = currentItem; }
- if (price!=0&&(money-price)>=0) { money -= price; orders++; }
- price = 0; currentItem = 0;
- }
- input = Console.ReadLine();
- }
- if (orders == 0)
- {
- Console.WriteLine("No purchases. Money left: {0:F2} lv.", money);
- }
- else
- {
- Console.WriteLine("{0} purchases. Money left: {1:F2} lv.", orders, money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement