Advertisement
gospod1978

Methods/Orders

Oct 11th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Methods
  5. {
  6.     public class Methods
  7.     {
  8.         public static void Main()
  9.         {
  10.  
  11.             string products = Console.ReadLine();
  12.  
  13.             int quantity = int.Parse(Console.ReadLine());
  14.  
  15.             TotalPrice(products, quantity);
  16.  
  17.         }
  18.  
  19.         public static void TotalPrice(string products, int quantity)
  20.         {
  21.             double price = 0;
  22.  
  23.             switch (products)
  24.             {
  25.                 case "coffee":
  26.                     price = 1.50 * quantity;
  27.                     Console.WriteLine($"{price:f2}");
  28.                     break;
  29.                 case "water":
  30.                     price = 1.00 * quantity;
  31.                     Console.WriteLine($"{price:f2}");
  32.                     break;
  33.                 case "coke":
  34.                     price = 1.40 * quantity;
  35.                     Console.WriteLine($"{price:f2}");
  36.                     break;
  37.                 case "snacks":
  38.                     price = 2.00 * quantity;
  39.                     Console.WriteLine($"{price:f2}");
  40.                     break;
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement