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 SoftUni
- {
- class Program
- {
- static void Main(string[] args)
- {
- float money = float.Parse(Console.ReadLine());
- string input = "";
- int purchases = 0;
- float x = 0.0f;
- do
- {
- input = Console.ReadLine();
- }while(input != "mall.Enter");
- input = Console.ReadLine();
- while(input != "mall.Exit")
- {
- for(byte i = 0; i < input.Length; i++)
- {
- if(input[i] == '%')
- {
- if(money > 0)
- {
- money /= 2;
- purchases++;
- }
- }else if(input[i] == '*')
- {
- money += 10;
- }else if(input[i] >= 65 && input[i] <= 90)
- {
- // uppercase letter
- x = input[i] / 2.0f;
- if(money >= x)
- {
- money -= x;
- purchases++;
- }
- }else if(input[i] >= 97 && input[i] <= 122)
- {
- // lowercase letter
- x = input[i] * 0.3f;
- if(money >= x)
- {
- money -= x;
- purchases++;
- }
- }else if(money >= input[i])
- {
- money -= input[i];
- purchases++;
- }
- }
- // read next line
- input = Console.ReadLine();
- }
- if(purchases > 0)
- Console.WriteLine("{0} purchases. Money left: {1:F2} lv.", purchases, money);
- else
- Console.WriteLine("No purchases. Money left: {0:F2} lv.", money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement