Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PassionDays
- {
- class Program
- {
- public static void Main(string[] args)
- {
- decimal moneyLinaHas = decimal.Parse(Console.ReadLine());
- decimal moneyLeft = moneyLinaHas;
- decimal disscount = 0.0m;
- int purchasesMade = 0;
- string enterCommand = Console.ReadLine();
- string exitCommand = "mall.Exit";
- string linaPurchases = string.Empty;
- while (enterCommand != "mall.Enter")
- {
- enterCommand = Console.ReadLine();
- }
- for (int currentBuy = 0; currentBuy < 20; currentBuy++)
- {
- linaPurchases = Console.ReadLine();
- if (linaPurchases == exitCommand)
- {
- break;
- }
- else
- {
- purchasesMade++;
- }
- for (int currentLetter = 0; currentLetter < linaPurchases.Length; currentLetter++)
- {
- if (linaPurchases[currentLetter] >= 'a' && linaPurchases[currentLetter] <= 'z')
- {
- disscount = linaPurchases[currentLetter] * 0.3m;
- if (disscount < moneyLeft)
- {
- moneyLeft -= disscount;
- }
- }
- else if (linaPurchases[currentLetter] >= 'A' && linaPurchases[currentLetter] <= 'Z')
- {
- disscount = linaPurchases[currentLetter] * 0.5m;
- if (disscount < moneyLeft)
- {
- moneyLeft -= disscount;
- }
- }
- else if (linaPurchases[currentLetter] == '%')
- {
- moneyLeft *= 0.5m;
- }
- else if (linaPurchases[currentLetter] == '*')
- {
- moneyLeft += 10;
- }
- }
- }
- if (purchasesMade == 0)
- {
- Console.WriteLine("No purchases. Money left: {0:f2} lv.", moneyLeft);
- }
- else
- {
- Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", purchasesMade, moneyLeft);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment