aggressiveviking

Untitled

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