Krasimir_Slavov

Fruit Shop

Sep 29th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 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. namespace Fruit_Shop
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string fruit = Console.ReadLine().ToLower();
  14.             string day = Console.ReadLine().ToLower();
  15.             double quantity = double.Parse(Console.ReadLine());
  16.  
  17.             double price = -1.0;
  18.  
  19.             if (day == "mondey" ||
  20.                 day == "tuesday" ||
  21.                 day == "wednesday" ||
  22.                 day == "thursday" ||
  23.                 day == "friday")
  24.             {
  25.                 if (fruit == "banana") price = 2.50;
  26.                 else if (fruit == "apple") price = 1.20;
  27.                 else if (fruit == "orange") price = 0.85;
  28.                 else if (fruit == "grapefruit") price = 1.45;
  29.                 else if (fruit == "kiwi") price = 2.70;
  30.                 else if (fruit == "pineapple") price = 5.50;
  31.                 else if (fruit == "grapes") price = 3.85;
  32.             }
  33.             if (day == "saturday" || day == "sunday")
  34.             {
  35.                 if (fruit == "banana") price = 2.70;
  36.                 else if (fruit == "apple") price = 1.25;
  37.                 else if (fruit == "orange") price = 0.90;
  38.                 else if (fruit == "grapefruit") price = 1.60;
  39.                 else if (fruit == "kiwi") price = 3.0;
  40.                 else if (fruit == "pineapple") price = 5.60;
  41.                 else if (fruit == "grapes") price = 4.20;
  42.             }
  43.             if (price > 0)
  44.             {
  45.                 double result = price * quantity;
  46.                 Console.WriteLine($"{result:F2}", result);
  47.             }
  48.             else
  49.             {
  50.                 Console.WriteLine("error");
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment