simonradev

Passion Days

Oct 18th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PassionDays
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             decimal moneyLinaHas = decimal.Parse(Console.ReadLine());
  10.             decimal moneyLeft = moneyLinaHas;
  11.             decimal disscount = 0.0m;
  12.             int purchasesMade = 0;
  13.             string enterCommand = Console.ReadLine();
  14.             string exitCommand = "mall.Exit";
  15.             string linaPurchases = string.Empty;
  16.            
  17.            
  18.             while (enterCommand != "mall.Enter")
  19.             {
  20.                 enterCommand = Console.ReadLine();
  21.             }
  22.            
  23.             for (int currentBuy = 0; currentBuy < 20; currentBuy++)
  24.             {
  25.                 linaPurchases = Console.ReadLine();
  26.                 if (linaPurchases == exitCommand)
  27.                 {
  28.                     break;
  29.                 }
  30.                 else
  31.                 {
  32.                     purchasesMade++;
  33.                 }
  34.                        
  35.                     for (int currentLetter = 0; currentLetter < linaPurchases.Length; currentLetter++)
  36.                     {
  37.                        
  38.                         if (linaPurchases[currentLetter] >= 'a' && linaPurchases[currentLetter] <= 'z')
  39.                             {
  40.                                 disscount = linaPurchases[currentLetter] * 0.3m;
  41.                                 if (disscount < moneyLeft)
  42.                                 {
  43.                                     moneyLeft -= disscount;
  44.                                 }
  45.                             }
  46.                             else if (linaPurchases[currentLetter] >= 'A' && linaPurchases[currentLetter] <= 'Z')
  47.                             {
  48.                                 disscount = linaPurchases[currentLetter] * 0.5m;
  49.                                 if (disscount < moneyLeft)
  50.                                 {
  51.                                     moneyLeft -= disscount;
  52.                                 }
  53.                             }
  54.                             else if (linaPurchases[currentLetter] == '%')
  55.                             {
  56.                                 moneyLeft *= 0.5m;
  57.                             }
  58.                             else if (linaPurchases[currentLetter] == '*')
  59.                             {
  60.                                 moneyLeft += 10;
  61.                             }
  62.                     }
  63.             }
  64.            
  65.             if (purchasesMade == 0)
  66.             {
  67.                 Console.WriteLine("No purchases. Money left: {0:f2} lv.", moneyLeft);
  68.             }
  69.             else
  70.             {
  71.                 Console.WriteLine("{0} purchases. Money left: {1:f2} lv.", purchasesMade, moneyLeft);
  72.             }
  73.            
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment