Advertisement
desislava_topuzakova

11. Fruit Shop

Jun 18th, 2022
1,373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FruitShop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string fruit = Console.ReadLine();
  10.             string day = Console.ReadLine();
  11.             double qty = double.Parse(Console.ReadLine());
  12.  
  13.             double totalSum = 0;
  14.  
  15.             switch (day)
  16.             {
  17.                 case "Monday":
  18.                 case "Tuesday":
  19.                 case "Wednesday":
  20.                 case "Thursday":
  21.                 case "Friday":
  22.                     switch (fruit)
  23.                     {
  24.                         case "banana":
  25.                             totalSum = qty * 2.50;
  26.                             break;
  27.                         case "apple":
  28.                             totalSum = qty * 1.20;
  29.                             break;
  30.                         case "orange":
  31.                             totalSum = qty * 0.85;
  32.                             break;
  33.                         case "grapefruit":
  34.                             totalSum = qty * 1.45;
  35.                             break;
  36.                         case "kiwi":
  37.                             totalSum = qty * 2.70;
  38.                             break;
  39.                         case "pineapple":
  40.                             totalSum = qty * 5.50;
  41.                             break;
  42.                         case "grapes":
  43.                             totalSum = qty * 3.85;
  44.                             break;
  45.                         default:
  46.                             Console.WriteLine("error");
  47.                             break;
  48.                     }
  49.                     break;
  50.                 case "Saturday":
  51.                 case "Sunday":
  52.                     switch (fruit)
  53.                     {
  54.                         case "banana":
  55.                             totalSum = qty * 2.70;
  56.                             break;
  57.                         case "apple":
  58.                             totalSum = qty * 1.25;
  59.                             break;
  60.                         case "orange":
  61.                             totalSum = qty * 0.90;
  62.                             break;
  63.                         case "grapefruit":
  64.                             totalSum = qty * 1.60;
  65.                             break;
  66.                         case "kiwi":
  67.                             totalSum = qty * 3.00;
  68.                             break;
  69.                         case "pineapple":
  70.                             totalSum = qty * 5.60;
  71.                             break;
  72.                         case "grapes":
  73.                             totalSum = qty * 4.20;
  74.                             break;
  75.                         default:
  76.                             Console.WriteLine("error");
  77.                             break;
  78.                     }
  79.                     break;
  80.                 default:
  81.                     Console.WriteLine("error");
  82.                     break;
  83.             }
  84.             if (totalSum > 0)
  85.             {
  86.                 Console.WriteLine($"{totalSum:f2}");
  87.  
  88.             }
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement