anizko

05. Orders

Jul 2nd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Orders
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string product = Console.ReadLine();
  10.             int quantityProduct = int.Parse(Console.ReadLine());
  11.             CalculatesTotaPriceOrder(product, quantityProduct);
  12.         }
  13.      
  14.         static void CalculatesTotaPriceOrder(string product,int quantityProduct)
  15.         {
  16.             double priceProduct = 0;
  17.  
  18.             switch(product)
  19.             {
  20.                 case "coffee":
  21.                     priceProduct = 1.50;
  22.                     break;
  23.                 case "coke":
  24.                     priceProduct = 1.40;
  25.                     break;
  26.                 case "water":
  27.                     priceProduct = 1.00;
  28.                     break;
  29.                 case "snacks":
  30.                     priceProduct = 2.00;
  31.                     break;
  32.             }
  33.             double totalPrice = quantityProduct * priceProduct;
  34.             Console.WriteLine($"{totalPrice:f2}");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment