kema

PassionDays

Apr 17th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.15 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.     class PassionDays
  7.     {
  8.         static void Main()
  9.         {
  10.             decimal money = decimal.Parse(Console.ReadLine());
  11.             string enter = Console.ReadLine();
  12.             long purchaseCounter = 0L;
  13.             decimal result = 0;
  14.             while (enter!="mall.Enter")
  15.             {
  16.                 if (enter == "mall.Exit")
  17.                 {
  18.                     break;
  19.                 }
  20.                 else
  21.                 {
  22.                     enter = Console.ReadLine();
  23.                     continue;
  24.                 }
  25.             }
  26.             while (enter != "mall.Exit")
  27.             {
  28.                 enter = Console.ReadLine();
  29.                 if (enter == "mall.Exit")
  30.                 {
  31.                     break;
  32.                 }
  33.                 else
  34.                 {                                    
  35.                     char[] symbols = new char[enter.Length];
  36.  
  37.                     for (int i = 0; i < enter.Length; i++)
  38.                     {
  39.                         symbols[i] = enter[i];
  40.                     }
  41.                     for (int i = 0; i < symbols.Length; i++)
  42.                     {
  43.                             if (symbols[i] >= 'A' && symbols[i] <= 'Z')
  44.                             {
  45.                                 result = money - symbols[i] / 2M;
  46.                                 if (result>=0)
  47.                                 {
  48.                                     money -= symbols[i] / 2M;
  49.                                     purchaseCounter++;
  50.                                 }
  51.                            
  52.                             }
  53.                             if (symbols[i] >= 'a' && symbols[i] <= 'z')
  54.                             {
  55.                                 var percent = symbols[i] * 0.3M;
  56.                                 result = money - percent;
  57.                                 if (result >= 0)
  58.                                 {
  59.                                     money -= percent;
  60.                                     purchaseCounter++;
  61.                                 }
  62.  
  63.                             }
  64.                             if (symbols[i] == '%' )
  65.                             {
  66.                                 result = money /2M;
  67.                                 if (result >= 0)
  68.                                 {
  69.                                     money /= 2M;
  70.                                     purchaseCounter++;
  71.                                 }
  72.  
  73.                             }
  74.                             if (symbols[i] == '*')
  75.                             {
  76.                                     money += 10;
  77.                                
  78.                             }
  79.  
  80.                     }
  81.                 }
  82.  
  83.             }
  84.             if (purchaseCounter==0)
  85.             {
  86.                 Console.WriteLine("No purchases. Money left: {0:0.00} lv.",money);
  87.             }
  88.             else
  89.             {
  90.                 Console.WriteLine("{0} purchases. Money left: {1:0.00} lv.",purchaseCounter, money);
  91.  
  92.             }
  93.         }
  94.     }
Advertisement
Add Comment
Please, Sign In to add comment