Guest User

Untitled

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