Advertisement
Valantina

CoffeeMachine/Exam

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