Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Fruit_Shop
- {
- class fruit_shop
- {
- static void Main(string[] args)
- {
- var days = new [] {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
- var fruits = new [] {"banana", "apple", "orange", "grapefruit", "kiwi", "pineapple", "grapes"};
- var regular_prices = new [] {2.50, 1.2, .85, 1.45, 2.7, 5.5, 2.85};
- var weekend_prices = new [] {2.7, 1.25, .9, 1.6, 3, 5.6, 4.2};
- var fruit = Console.ReadLine().ToLower();
- var day = Console.ReadLine().ToLower();
- var quantity = double.Parse(Console.ReadLine());
- var iday = Array.IndexOf(days, day);
- var ifruit = Array.IndexOf(fruits, fruit);
- if(iday == -1 || ifruit == -1)
- Console.WriteLine("error");
- else {
- var prices = iday < 5 ? regular_prices : weekend_prices;
- Console.WriteLine("{0:N2}", quantity*prices[ifruit]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement