MiroslavKisov

Passion_Days

Aug 30th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Passion_Days
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal startMoney = decimal.Parse(Console.ReadLine());
  14.             string mallAction = Console.ReadLine();
  15.             decimal price = 0.0m;
  16.             char[] symbol = new char[20];
  17.             int purchaseCounter = 0;
  18.             while (mallAction != "mall.Enter")
  19.             {
  20.                 mallAction = Console.ReadLine();
  21.             }
  22.             while (mallAction != "mall.Exit")
  23.             {
  24.                 mallAction = Console.ReadLine();
  25.                 if (mallAction=="mall.Exit")
  26.                 {
  27.                     break;
  28.                 }
  29.                 symbol = mallAction.ToCharArray();
  30.                 for (int i = 0; i < symbol.Length; i++)
  31.                 {
  32.                     if (char.IsLetter(symbol[i]) && char.IsUpper(symbol[i]))
  33.                     {
  34.                         price = symbol[i];
  35.                         price *= 0.5m;
  36.                         if (price > startMoney)
  37.                         {
  38.                             continue;
  39.                         }
  40.                         startMoney -= price;
  41.                         purchaseCounter++;
  42.                     }
  43.                     else if (char.IsLetter(symbol[i]) && char.IsLower(symbol[i]))
  44.                     {
  45.                         price = symbol[i];
  46.                         price *= 0.3m;
  47.                         if (price > startMoney)
  48.                         {
  49.                             continue;
  50.                         }
  51.                         startMoney -= price;
  52.                         purchaseCounter++;
  53.                     }
  54.                     else if (symbol[i] == '%')
  55.                     {
  56.                         if (startMoney<=0)
  57.                         {
  58.                             continue;
  59.                         }
  60.                         startMoney /= 2;
  61.                         purchaseCounter++;
  62.                     }
  63.                     else if (symbol[i] == '*')
  64.                     {
  65.                         startMoney += 10;
  66.                     }
  67.                     else
  68.                     {
  69.                         price = symbol[i];
  70.                         if (price > startMoney)
  71.                         {
  72.                             continue;
  73.                         }
  74.                         startMoney -= price;
  75.                         purchaseCounter++;
  76.                     }
  77.                 }
  78.             }
  79.             if (purchaseCounter==0)
  80.             {
  81.                 Console.WriteLine("No purchases. Money left: {0:f2} lv.", startMoney);
  82.             }
  83.             else
  84.             {
  85.                 Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", purchaseCounter, startMoney);
  86.             }
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment