Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter the product you want: ");
- string product = Console.ReadLine();
- Console.Write("Enter the quantity you want: ");
- int quantity = int.Parse(Console.ReadLine());
- Console.WriteLine("The price is: {0:F2}",Order(product,quantity));
- }
- static double Order(string product,int quantity)
- {
- double sum = 0;
- double coffeePrice = 1.5;
- double waterPrice = 1;
- double cokePrice = 1.4;
- double snacksPrice = 2;
- switch (product)
- {
- case "coffee":
- sum = coffeePrice * quantity;
- break;
- case "water":
- sum = waterPrice * quantity;
- break;
- case "coke":
- sum = cokePrice * quantity;
- break;
- case "snacks":
- sum = snacksPrice * quantity;
- break;
- default:
- sum = 0;
- break;
- }
- return sum;
- }
- }
- }
Add Comment
Please, Sign In to add comment