Advertisement
IvanITD

05.SmallShop

Jan 15th, 2024
1,075
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | Source Code | 0 0
  1. string product = Console.ReadLine();
  2. string city = Console.ReadLine();
  3. double quantity = double.Parse(Console.ReadLine());
  4.  
  5. double coffee;
  6. double water;
  7. double beer;
  8. double sweets;
  9. double peanuts;
  10.  
  11. // Here we solved the task using the if else statement
  12.  
  13. if (city == "Sofia")
  14. {
  15.     if (product == "coffee")
  16.     {
  17.         coffee = 0.50;
  18.         quantity *= coffee;
  19.     }
  20.     else if (product == "water")
  21.     {
  22.         water = 0.80;
  23.         quantity *= water;
  24.     }
  25.     else if (product == "beer")
  26.     {
  27.         beer = 1.20;
  28.         quantity *= beer;
  29.     }
  30.     else if (product == "sweets")
  31.     {
  32.         sweets = 1.45;
  33.         quantity *= sweets;
  34.     }
  35.     else if (product == "peanuts")
  36.     {
  37.         peanuts = 1.60;
  38.         quantity *= peanuts;
  39.     }
  40. }
  41. else if (city == "Plovdiv")
  42. {
  43.     if (product == "coffee")
  44.     {
  45.         coffee = 0.40;
  46.         quantity *= coffee;
  47.     }
  48.     else if (product == "water")
  49.     {
  50.         water = 0.70;
  51.         quantity *= water;
  52.     }
  53.     else if (product == "beer")
  54.     {
  55.         beer = 1.15;
  56.         quantity *= beer;
  57.     }
  58.     else if (product == "sweets")
  59.     {
  60.         sweets = 1.30;
  61.         quantity *= sweets;
  62.     }
  63.     else if (product == "peanuts")
  64.     {
  65.         peanuts = 1.50;
  66.         quantity *= peanuts;
  67.     }
  68. }
  69. else if (city == "Varna")
  70. {
  71.     if (product == "coffee")
  72.     {
  73.         coffee = 0.45;
  74.         quantity *= coffee;
  75.     }
  76.     else if (product == "water")
  77.     {
  78.         water = 0.70;
  79.         quantity *= water;
  80.     }
  81.     else if (product == "beer")
  82.     {
  83.         beer = 1.10;
  84.         quantity *= beer;
  85.     }
  86.     else if (product == "sweets")
  87.     {
  88.         sweets = 1.35;
  89.         quantity *= sweets;
  90.     }
  91.     else if (product == "peanuts")
  92.     {
  93.         peanuts = 1.55;
  94.         quantity *= peanuts;
  95.     }
  96. }
  97. Console.WriteLine(quantity);
  98.  
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement