Advertisement
Kuncavia

07. FruitShop

Nov 27th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. using System;
  2.  
  3. class FruitShop
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         var fruit = Console.ReadLine().ToLower();
  8.         var day = Console.ReadLine().ToLower();
  9.         var quantity = double.Parse(Console.ReadLine().ToLower());
  10.         var price = -1.0;
  11.  
  12.         if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday")
  13.         {
  14.             if (fruit == "banana")
  15.             {
  16.                 price = quantity * 2.50;
  17.             }
  18.             else if (fruit == "apple")
  19.             {
  20.                 price = quantity * 1.20;
  21.             }
  22.             else if (fruit == "orange")
  23.             {
  24.                 price = quantity * 0.85;
  25.             }
  26.             else if (fruit == "grapefruit")
  27.             {
  28.                 price = quantity * 1.45;
  29.             }
  30.             else if (fruit == "kiwi")
  31.             {
  32.                 price = quantity * 2.70;
  33.             }
  34.             else if (fruit == "pineapple")
  35.             {
  36.                 price = quantity * 5.50;
  37.             }
  38.             else if (fruit == "grapes")
  39.             {
  40.                 price = quantity * 3.85;
  41.             }
  42.         }
  43.         else if (day == "sunday" || day == "saturday")
  44.         {
  45.             if (fruit == "banana")
  46.             {
  47.                 price = quantity * 2.70;
  48.             }
  49.             else if (fruit == "apple")
  50.             {
  51.                 price = quantity * 1.25;
  52.             }
  53.             else if (fruit == "orange")
  54.             {
  55.                 price = quantity * 0.90;
  56.             }
  57.             else if (fruit == "grapefruit")
  58.             {
  59.                 price = quantity * 1.60;
  60.             }
  61.             else if (fruit == "kiwi")
  62.             {
  63.                 price = quantity * 3.00;
  64.             }
  65.             else if (fruit == "pineapple")
  66.             {
  67.                 price = quantity * 5.60;
  68.             }
  69.             else if (fruit == "grapes")
  70.             {
  71.                 price = quantity * 4.20;
  72.             }
  73.         }
  74.         if (price >= 0)
  75.         {
  76.             Console.WriteLine("{0:F2}", price);
  77.         }
  78.         else
  79.         {
  80.             Console.WriteLine("error");
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement