Advertisement
simonradev

FruitShop

May 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Statements
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             string fruit = Console.ReadLine().ToLower();
  10.             string day = Console.ReadLine().ToLower();
  11.             var ammount = double.Parse(Console.ReadLine());
  12.  
  13.             bool dayIsNotWeekend = day != "sunday" && day != "saturday";
  14.             double price = -1.0;
  15.  
  16.             if (fruit == "banana")
  17.             {
  18.                 price = dayIsNotWeekend ? 2.50 : 2.70;
  19.             }
  20.             else if (fruit == "apple")
  21.             {
  22.                 price = dayIsNotWeekend ? 1.20 : 1.25;
  23.             }
  24.             else if (fruit == "orange")
  25.             {
  26.                 price = dayIsNotWeekend ? 0.85 : 0.9;
  27.             }
  28.             else if (fruit == "grapefruit")
  29.             {
  30.                 price = dayIsNotWeekend ? 1.45 : 1.60;
  31.             }
  32.             else if (fruit == "kiwi")
  33.             {
  34.                 price = dayIsNotWeekend ? 2.70 : 3.00;
  35.             }
  36.             else if (fruit == "pineapple")
  37.             {
  38.                 price = dayIsNotWeekend ? 5.50 : 5.60;
  39.             }
  40.             else if (fruit == "grapes")
  41.             {
  42.                 price = dayIsNotWeekend ? 3.85 : 4.20;
  43.             }
  44.  
  45.             double result = ammount * price;
  46.  
  47.            
  48.             if ((day == "monday" ||
  49.                  day == "tuesday" ||
  50.                  day == "wednesday" ||
  51.                  day == "thursday" ||
  52.                  day == "friday" ||
  53.                  day == "saturday" ||
  54.                  day == "sunday") &&
  55.                  result >= 0)
  56.             {
  57.                 Console.WriteLine(Math.Round(result, 2));
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine("error");
  62.             }
  63.  
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement