Advertisement
braveheart1989

"Fruit Shop"

Feb 9th, 2016
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Fruit_Shop
  8. {
  9.     static void Main()
  10.     {
  11.         string fruit = Console.ReadLine();
  12.         string dayOfWeek = Console.ReadLine();
  13.         decimal amount = decimal.Parse(Console.ReadLine());
  14.         decimal bananaPrice = 2.50M;
  15.         decimal applePrice = 1.20M;
  16.         decimal orangePrice = 0.85M;
  17.         decimal grapefruitPrice = 1.45M;
  18.         decimal kiwiPrice = 2.70M;
  19.         decimal pineapplePrice = 5.50M;
  20.         decimal grapesPrice = 3.85M;
  21.  
  22.         if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" || dayOfWeek == "Friday")
  23.         {
  24.             switch (fruit)
  25.             {
  26.                 case "banana":
  27.                     Console.WriteLine("{0:F2}", bananaPrice * amount);
  28.                     break;
  29.                 case "apple":
  30.                     Console.WriteLine("{0:F2}", applePrice * amount);
  31.                     break;
  32.                 case "orange":
  33.                     Console.WriteLine("{0:F2}", orangePrice * amount);
  34.                     break;
  35.                 case "grapefruit":
  36.                     Console.WriteLine("{0:F2}", grapefruitPrice * amount);
  37.                     break;
  38.                 case "kiwi":
  39.                     Console.WriteLine("{0:F2}", kiwiPrice * amount);
  40.                     break;
  41.                 case "pineapple":
  42.                     Console.WriteLine("{0:F2}", pineapplePrice * amount);
  43.                     break;
  44.                 case "grapes":
  45.                     Console.WriteLine("{0:F2}", grapesPrice * amount);
  46.                     break;
  47.                 default:
  48.                     Console.WriteLine("error");
  49.                     break;
  50.             }
  51.         }
  52.         else if (dayOfWeek == "Saturday" || dayOfWeek == "Sunday")
  53.         {
  54.             switch (fruit)
  55.             {
  56.                 case "banana":
  57.                     Console.WriteLine("{0:F2}", (bananaPrice + 0.20M) * amount);
  58.                     break;
  59.                 case "apple":
  60.                     Console.WriteLine("{0:F2}", (applePrice + 0.05M) * amount);
  61.                     break;
  62.                 case "orange":
  63.                     Console.WriteLine("{0:F2}", (orangePrice + 0.05M) * amount);
  64.                     break;
  65.                 case "grapefruit":
  66.                     Console.WriteLine("{0:F2}", (grapefruitPrice + 0.15M) * amount);
  67.                     break;
  68.                 case "kiwi":
  69.                     Console.WriteLine("{0:F2}", (kiwiPrice + 0.30M) * amount);
  70.                     break;
  71.                 case "pineapple":
  72.                     Console.WriteLine("{0:F2}", (pineapplePrice + 0.10M) * amount);
  73.                     break;
  74.                 case "grapes":
  75.                     Console.WriteLine("{0:F2}", (grapesPrice + 0.35M) * amount);
  76.                     break;
  77.                 default:
  78.                     Console.WriteLine("error");
  79.                     break;
  80.             }
  81.         }
  82.         else
  83.         {
  84.             Console.WriteLine("error");
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement