Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- string product = Console.ReadLine().ToLower();
- string city = Console.ReadLine().ToLower();
- double quantity = double.Parse(Console.ReadLine());
- double price;
- //SCROLL DOWN TO SEE THE SWITCH-CASE SOLUTION
- //SCROLL DOWN TO SEE THE SWITCH-CASE SOLUTION
- //if (city == "sofia")
- //{
- // if (product == "coffee") { price = 0.50; }
- // else if (product == "water") { price = 0.80; }
- // else if (product == "beer") { price = 1.20; }
- // else if (product == "sweets") { price = 1.45; }
- // else if (product == "peanuts") { price = 1.60; }
- //}
- //else if (city == "plovdiv")
- //{
- // if (product == "coffee") { price = 0.40; }
- // else if (product == "water") { price = 0.70; }
- // else if (product == "beer") { price = 1.15; }
- // else if (product == "sweets") { price = 1.30; }
- // else if (product == "peanuts") { price = 1.50; }
- //}
- //else if (city == "varna")
- //{
- // if (product == "coffee") { price = 0.45; }
- // else if (product == "water") { price = 0.70; }
- // else if (product == "beer") { price = 1.10; }
- // else if (product == "sweets") { price = 1.35; }
- // else if (product == "peanuts") { price = 1.55; }
- //}
- //Console.WriteLine("{0:F2}", quantity * price);
- switch (city)
- {
- case "sofia":
- if (product == "coffee")
- { price = 0.50; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "water")
- { price = 0.80; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "beer")
- { price = 1.20; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "sweets")
- { price = 1.30; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "peanuts")
- { price = 1.50; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- case "plovdiv":
- if (product == "coffee")
- { price = 0.40; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "water")
- { price = 0.70; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "beer")
- { price = 1.15; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "sweets")
- { price = 1.30; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "peanuts")
- { price = 1.50; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- case "varna":
- if (product == "coffee")
- { price = 0.45; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "water")
- { price = 0.70; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "beer")
- { price = 1.10; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "sweets")
- { price = 1.35; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- if (product == "peanuts")
- { price = 1.55; }
- Console.WriteLine("{0:F2}", quantity * price);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement