Advertisement
ad2bg

FruitShop

Oct 28th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.64 KB | None | 0 0
  1. namespace FruitShop
  2. {
  3.     using System;
  4.  
  5.     class FruitShop
  6.     {
  7.         static void Main()
  8.         {
  9.             var fruit = Console.ReadLine().ToLower();
  10.             var day = Console.ReadLine().ToLower();
  11.             var qty = double.Parse(Console.ReadLine());
  12.  
  13.             var price = 0.0;
  14.  
  15.             if (!(day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday" || day == "saturday" || day == "sunday"))
  16.             {
  17.                 Console.WriteLine("error");
  18.                 return;
  19.             }
  20.  
  21.             if (!(fruit == "banana" || fruit == "apple" || fruit == "orange" || fruit == "grapefruit" || fruit == "kiwi" || fruit == "pineapple" || fruit == "grapes"))
  22.             {
  23.                 Console.WriteLine("error");
  24.                 return;
  25.             }
  26.  
  27.             if (day == "saturday" || day == "sunday")
  28.             {
  29.                 if (fruit == "banana")
  30.                 {
  31.                     price = 2.70;
  32.                 }
  33.                 else if (fruit == "apple")
  34.                 {
  35.                     price = 1.25;
  36.                 }
  37.                 else if (fruit == "orange")
  38.                 {
  39.                     price = 0.9;
  40.                 }
  41.                 else if (fruit == "grapefruit")
  42.                 {
  43.                     price = 1.6;
  44.                 }
  45.                 else if (fruit == "kiwi")
  46.                 {
  47.                     price = 3.0;
  48.                 }
  49.                 else if (fruit == "pineapple")
  50.                 {
  51.                     price = 5.6;
  52.                 }
  53.                 else if (fruit == "grapes")
  54.                 {
  55.                     price = 4.2;
  56.                 }
  57.             }
  58.             else
  59.             {
  60.                 if (fruit == "banana")
  61.                 {
  62.                     price = 2.5;
  63.                 }
  64.                 else if (fruit == "apple")
  65.                 {
  66.                     price = 1.2;
  67.                 }
  68.                 else if (fruit == "orange")
  69.                 {
  70.                     price = 0.85;
  71.                 }
  72.                 else if (fruit == "grapefruit")
  73.                 {
  74.                     price = 1.45;
  75.                 }
  76.                 else if (fruit == "kiwi")
  77.                 {
  78.                     price = 2.7;
  79.                 }
  80.                 else if (fruit == "pineapple")
  81.                 {
  82.                     price = 5.5;
  83.                 }
  84.                 else if (fruit == "grapes")
  85.                 {
  86.                     price = 3.85;
  87.                 }
  88.             }
  89.  
  90.  
  91.             Console.WriteLine(Math.Round(price * qty, 2));
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement