Advertisement
Guest User

Untitled

a guest
Sep 29th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 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. namespace _04.OnlineRadioDatabase
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string fruit = Console.ReadLine();
  13.             string day = Console.ReadLine();
  14.             double quantity = double.Parse(Console.ReadLine());
  15.  
  16.             var price1 = new Dictionary<string, double>()
  17.             {
  18.                 { "banana", 2.50 },
  19.                 { "apple", 1.20 },
  20.                 { "orange", 0.85 },
  21.                 { "grapefruit", 1.45 },
  22.                 { "kiwi", 2.70 },
  23.                 { "pineapple", 5.50 },
  24.                 { "grapes", 3.85 }
  25.             };
  26.  
  27.             var price2 = new Dictionary<string, double>()
  28.             {
  29.                 { "banana", 2.70 },
  30.                 { "apple", 1.25 },
  31.                 { "orange", 0.90 },
  32.                 { "grapefruit", 1.60 },
  33.                 { "kiwi", 3.00 },
  34.                 { "pineapple", 5.60 },
  35.                 { "grapes", 4.20 }
  36.             };
  37.  
  38.  
  39.             if (fruit == "banana" || fruit == "apple" || fruit == "orange" || fruit == "grapefruit" || fruit == "kiwi" || fruit == "pineapple" || fruit == "grapes")
  40.             {
  41.                 double result1 = quantity * price1[fruit];
  42.                 double result2 = quantity * price2[fruit];
  43.                 if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday") Console.WriteLine("{0:0.00}", result1);
  44.  
  45.                 else if (day == "Saturday" || day == "Sunday") Console.WriteLine("{0:0.00}", result2);
  46.  
  47.                 else Console.WriteLine("error");
  48.             }
  49.             else
  50.             {
  51.                 Console.WriteLine("error");
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement