pavlinpetkov88

FruitShop

Nov 10th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 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 ConsoleApplication7
  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.             var quantity = double.Parse(Console.ReadLine());
  16.  
  17.             double price = -1;
  18.            
  19.  
  20.             if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday")
  21.             {
  22.                 if (fruit == "banana") price = 2.50;
  23.                 else if (fruit == "apple") price = 1.20;
  24.                 else if (fruit == "orange") price = 0.85;
  25.                 else if (fruit == "grapefruit") price = 1.45;
  26.                 else if (fruit == "kiwi") price = 2.70;
  27.                 else if (fruit == "pineapple") price = 5.50;
  28.                 else if (fruit == "grapes") price = 3.85;
  29.             }
  30.  
  31.             else if (day == "saturday" || day == "sunday")
  32.             {
  33.                 if (fruit == "banana") price = 2.70;
  34.                 else if (fruit == "apple") price = 1.25;
  35.                 else if (fruit == "orange") price = 0.90;
  36.                 else if (fruit == "grapefruit")  price = 1.60;
  37.                 else if (fruit == "kiwi")  price = 3.00;
  38.                 else if (fruit == "pineapple")  price = 5.60;
  39.                 else if (fruit == "grapes")  price = 4.20;
  40.             }
  41.             if (price >= 0)
  42.             {
  43.                 var result = price * quantity;
  44.                 Console.WriteLine("{0:f2}", result);
  45.             }
  46.             else
  47.             {
  48.                 Console.WriteLine("error");
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment