Advertisement
aggressiveviking

03.CoffeeMachine

Feb 26th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.CoffeeMachine
  4. {
  5.     class CoffeeMachine
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string drink = Console.ReadLine();
  10.             string sugar = Console.ReadLine();
  11.             int cups = int.Parse(Console.ReadLine());
  12.            
  13.             double price = 0.0;
  14.  
  15.             switch (drink)
  16.             {
  17.                 case "Espresso":
  18.                     if ("Without" == sugar)
  19.                     {
  20.                         price = price + 0.90 * cups;
  21.                         price = price * 0.65;
  22.                     }
  23.                     else if ("Normal" == sugar)
  24.                     {
  25.                         price = price + 1.00 * cups;
  26.                     }
  27.                     else if ("Extra" == sugar)
  28.                     {
  29.                         price = price + 1.20 * cups;
  30.                     }
  31.                     if (price >= 5)
  32.                     {
  33.                         price = price * 0.75;
  34.                     }
  35.                     break;
  36.                 case "Cappuccino":
  37.                     if ("Without" == sugar)
  38.                     {
  39.                         price = price + 1.00 * cups;
  40.                         price *= 0.65;
  41.                     }
  42.                     else if ("Normal" == sugar)
  43.                     {
  44.                         price = price + 1.20 * cups;
  45.                     }
  46.                     else if ("Extra" == sugar)
  47.                     {
  48.                         price = price + 1.60 * cups;
  49.                     }
  50.                     break;
  51.                 case "Tea":
  52.                     if ("Without" == sugar)
  53.                     {
  54.                         price = price + 0.50 * cups;
  55.                         price *= 0.65;
  56.                     }
  57.                     else if ("Normal" == sugar)
  58.                     {
  59.                         price = price + 0.60 * cups;
  60.                     }
  61.                     else if ("Extra" == sugar)
  62.                     {
  63.                         price = price + 0.70 * cups;
  64.                     }
  65.                     break;
  66.             }
  67.  
  68.             if (price > 15.0)
  69.             {
  70.                 price = price * 0.8;
  71.             }
  72.  
  73.             Console.WriteLine($"You bought {cups} cups of {drink} for {price:F2} lv.");
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement