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 PassionDays
- {
- class PassionDays
- {
- static void Main(string[] args)
- {
- var money = decimal.Parse(Console.ReadLine());
- string input;
- char inputChar;
- var purchases = 0;
- bool exit = false;
- while (exit == false)
- {
- var start = Console.ReadLine();
- if (start == "mall.Enter")
- {
- while (true)
- {
- input = Console.ReadLine();
- if (input == "mall.Exit")
- {
- exit = true;
- break;
- }
- else
- {
- //loop the string
- for (int i = 0; i < input.Length; i++)
- {
- inputChar = input[i];
- //add mone no purchase
- if (inputChar == '*')
- {
- money += 10;
- }
- //halves the money
- else if (inputChar == '%' && money > 0)
- {
- money /= 2.0M;
- purchases++;
- }
- //char is letter
- else if (char.IsLetter(inputChar))
- {
- if (char.IsUpper(inputChar) && (int)(inputChar) * 0.5M <= money)
- {
- purchases++;
- money -= (int)(inputChar) * 0.5M;
- }
- else if (char.IsLower(inputChar) && (int)(inputChar) * 0.3M <= money)
- {
- purchases++;
- money -= (int)(inputChar) * 0.3M;
- }
- }
- else
- {
- if ((int)(inputChar) <= money)
- {
- money -= (int)(inputChar);
- purchases++;
- }
- }
- }
- }
- }
- }
- }
- if (purchases > 0)
- {
- Console.WriteLine($"{purchases} purchases. Money left: {money:F2} lv.");
- }
- else
- {
- Console.WriteLine($"No purchases. Money left: {money:f2} lv.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement