Advertisement
Guest User

Fruit_shop

a guest
Mar 2nd, 2016
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 _07.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.             double price = -1.0;
  17.  
  18.             var fruitsDays = new Dictionary<string, double>
  19.             {
  20.                 {"banana",  2.50},
  21.                 {"apple",  1.20},
  22.                 {"orange",  0.85},
  23.                 {"grapefruit",  1.45},
  24.                 {"kiwi",  2.70},
  25.                 {"pineapple",  5.50},
  26.                 {"grapes",  3.85},
  27.             };
  28.             var fruitsWeekend = new Dictionary<string, double>
  29.             {
  30.                 {"banana",  2.70},
  31.                 {"apple",  1.25},
  32.                 {"orange",  0.90},
  33.                 {"grapefruit",  1.60},
  34.                 {"kiwi",  3.00},
  35.                 {"pineapple",  5.60},
  36.                 {"grapes",  4.20},
  37.             };
  38.  
  39.             if (day == "monday") price = quantity * fruitsDays[fruit];
  40.             else if (day == "tuesday") price = quantity * fruitsDays[fruit];
  41.             else if (day == "wednesday") price = quantity * fruitsDays[fruit];
  42.             else if (day == "thursday") price = quantity * fruitsDays[fruit];
  43.             else if (day == "friday") price = quantity * fruitsDays[fruit];
  44.             else if (day == "saturday") price = quantity * fruitsWeekend[fruit];
  45.             else if (day == "sunday") price = quantity * fruitsWeekend[fruit];
  46.  
  47.             if (price >= 0)
  48.             {
  49.                 Console.WriteLine("{0:f2}", price);
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine("error");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement