Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main(string[] args)
- {
- string fruit = Console.ReadLine();
- string day = Console.ReadLine();
- double quantity = double.Parse(Console.ReadLine());
- bool isValidDay = day == "Monday" || day == "Tuesday" ||
- day == "Wednesday" || day == "Thursday" ||
- day == "Friday" || day == "Saturday" ||
- day == "Sunday";
- bool isWeekend = day == "Saturday" || day == "Sunday";
- var fruitPrices = new Dictionary<string, double>()
- {
- { "banana",isWeekend? 2.70:2.50 },
- { "apple",isWeekend? 1.25:1.20 },
- { "orange",isWeekend? 0.90:0.85 },
- { "grapefruit",isWeekend?1.60 :1.45 },
- { "kiwi", isWeekend?3.00:2.70 },
- { "pineapple",isWeekend? 5.60: 5.50},
- { "grapes",isWeekend?4.20: 3.85 }
- };
- if (isValidDay && fruitPrices.ContainsKey(fruit))
- {
- Console.WriteLine((fruitPrices[fruit] * quantity).ToString("F2"));
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement