gadjov

Untitled

Mar 10th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 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 Passiondays
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // A = 50%
  14.             // a = 70%
  15.             // % = /50
  16.             // * = +10lv
  17.             decimal moneyStart = decimal.Parse(Console.ReadLine());
  18.             string line = Console.ReadLine();
  19.             int puchases = 0;
  20.             while (line != "mall.Enter")
  21.             {
  22.                 line = Console.ReadLine();
  23.             }
  24.             line = Console.ReadLine();
  25.             while (line != "mall.Exit")
  26.             {
  27.                 string actions = line;
  28.                 for (int i = 0; i < actions.Length; i++)
  29.                 {
  30.                     decimal price = 0;
  31.                     if (actions[i] >= 65 && actions[i] <= 90)
  32.                     {
  33.                         price = actions[i] * 0.5m;
  34.                         if (moneyStart < price)
  35.                         {
  36.                             break;
  37.                         }
  38.                         moneyStart -= price;
  39.                         puchases++;
  40.                     }
  41.                     else if (actions[i] >= 97 && actions[i] <= 122)
  42.                     {
  43.                         price = actions[i] * 0.3m;
  44.                         if (moneyStart < price)
  45.                         {
  46.                             break;
  47.                         }
  48.                         moneyStart -= price;
  49.                         puchases++;
  50.                     }
  51.                     else if (actions[i] == '%')
  52.                     {
  53.                         moneyStart /= 2;
  54.                         puchases++;
  55.                     }
  56.                     else if (actions[i] == '*')
  57.                     {
  58.                         moneyStart += 10;
  59.                     }
  60.                     else
  61.                     {
  62.                         moneyStart -= price;
  63.                         puchases++;
  64.                     }
  65.                     }
  66.                     line = Console.ReadLine();
  67.                 }
  68.             if (puchases == 0)
  69.             {
  70.                 Console.WriteLine("No purchases. Money left: {0:f2} lv.", moneyStart);
  71.             }
  72.             else
  73.             {
  74.                 Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", puchases, moneyStart);
  75.             }
  76.             }
  77.         }
  78.     }
Add Comment
Please, Sign In to add comment