Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- var fruit = Console.ReadLine();
- var dayOfWeek = Console.ReadLine();
- var calculation = double.Parse(Console.ReadLine());
- string[] workdaysDays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
- string[] weekendDays = { "Saturday", "Sunday" };
- Dictionary<string, double> workdays = new Dictionary<string, double>();
- workdays.Add("banana", 2.50);
- workdays.Add("apple", 1.20);
- workdays.Add("orange", 0.85);
- workdays.Add("grapefruit", 1.45);
- workdays.Add("kiwi", 2.70);
- workdays.Add("pineapple", 5.50);
- workdays.Add("grapes", 3.85);
- Dictionary<string, double> weekend = new Dictionary<string, double>();
- weekend.Add("banana", 2.70);
- weekend.Add("apple", 1.25);
- weekend.Add("orange", 0.90);
- weekend.Add("grapefruit", 1.60);
- weekend.Add("kiwi", 3.00);
- weekend.Add("pineapple", 5.60);
- weekend.Add("grapes", 4.20);
- if (workdaysDays.Any(dayOfWeek.Contains))
- {
- try
- {
- var price = workdays[fruit];
- Console.WriteLine($"{price*calculation:f2}");
- }
- catch (Exception)
- {
- Console.WriteLine("error");
- }
- }
- else if(weekendDays.Any(dayOfWeek.Contains))
- {
- try
- {
- var price = weekend[fruit];
- Console.WriteLine($"{price * calculation:f2}");
- }
- catch (Exception)
- {
- Console.WriteLine("error");
- }
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement