11. Fruit Shop (Switch Construction)

ivanitd

Ivan Ivanov

Posted on January 20, 2023

11. Fruit Shop (Switch Construction)
using System;

namespace FruitShop_Switch_
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string fruit = Console.ReadLine();
            string weekDay = Console.ReadLine();
            double quantity = double.Parse(Console.ReadLine());

            double price = 0.0;

            switch (weekDay)
            {
                case "Monday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.45;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 3.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Tuesday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.45;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 3.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Wednesday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.45;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 3.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Thursday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.45;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 3.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Friday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.45;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.50;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 3.85;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Saturday":
                    switch (fruit)
                    {

                        case "banana":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.25;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.90;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.60;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 3.00;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.60;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 4.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                case "Sunday":
                    switch (fruit)
                    {
                        case "banana":
                            price = quantity * 2.70;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "apple":
                            price = quantity * 1.25;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "orange":
                            price = quantity * 0.90;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapefruit":
                            price = quantity * 1.60;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "kiwi":
                            price = quantity * 3.00;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "pineapple":
                            price = quantity * 5.60;
                            Console.WriteLine($"{price:F2}");
                            break;

                        case "grapes":
                            price = quantity * 4.20;
                            Console.WriteLine($"{price:F2}");
                            break;

                        default:
                            Console.WriteLine("error");
                            break;
                    }
                    break;

                default:
                    Console.WriteLine("error");
                    break;
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
ivanitd
Ivan Ivanov

Posted on January 20, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

10. Invalid Number
csharp 10. Invalid Number

January 20, 2023

11. Fruit Shop (Switch Construction)
csharp 11. Fruit Shop (Switch Construction)

January 20, 2023