Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- class FruitShop
- {
- static void Main()
- {
- string fruit = Console.ReadLine();
- string dayOfWeek = Console.ReadLine();
- double quantity = double.Parse(Console.ReadLine());
- double price;
- var daysOfWeek = new List<string> { "Monday", "Tuesday", "Wednesday", "Thirsday", "Friday" };
- var daysOfWeekend = new List<string> { "Saturday", "Sunday" };
- Dictionary<string, double> pricesWeek = new Dictionary<string, double>
- { { "banana", 2.50 }, { "apple", 1.20}, { "orange", 0.85},
- {"grapefruit", 1.45}, {"kiwi", 2.70}, { "pineapple", 5.50}, { "grapes", 3.85}
- };
- Dictionary<string, double> pricesWeekend = new Dictionary<string, double>
- { { "banana", 2.70 }, { "apple", 1.25}, { "orange", 0.90},
- {"grapefruit", 1.60}, {"kiwi", 3.00}, { "pineapple", 5.60}, { "grapes", 4.20}
- };
- if ((daysOfWeek.Contains(dayOfWeek)) && (pricesWeek.ContainsKey(fruit)))
- {
- price = quantity * pricesWeek[fruit];
- Console.WriteLine("{0:f2}", price);
- }
- else if ((daysOfWeekend.Contains(dayOfWeek)) && (pricesWeekend.ContainsKey(fruit)))
- {
- price = quantity * pricesWeekend[fruit];
- Console.WriteLine("{0:f2}", price);
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement