12. Trade Commissions (If Construction)

ivanitd

Ivan Ivanov

Posted on January 20, 2023

12. Trade Commissions (If Construction)
using System;

namespace TradeCommissions
{
internal class Program
{
    static void Main(string[] args)
    {
        string city = Console.ReadLine();
        double sales = double.Parse(Console.ReadLine());

        if (city == "Sofia")
        {
            if (sales >= 0 && sales <= 500)
            {
                sales *= 0.05;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 500 && sales <= 1_000)
            {
                sales *= 0.07;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 1_000 && sales <= 10_000)
            {
                sales *= 0.08;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 10_000)
            {
                sales *= 0.12;
                Console.WriteLine($"{sales:F2}");
            }
            else
            {
                Console.WriteLine("error");
            }
        }
        else if (city == "Varna")
        {
            if (sales >= 0 && sales <= 500)
            {
                sales *= 0.045;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 500 && sales <= 1_000)
            {
                sales *= 0.075;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 1_000 && sales <= 10_000)
            {
                sales *= 0.1;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 10_000)
            {
                sales *= 0.13;
                Console.WriteLine($"{sales:F2}");
            }
            else
            {
                Console.WriteLine("error");
            }
        }
        else if (city == "Plovdiv")
        {
            if (sales >= 0 && sales <= 500)
            {
                sales *= 0.055;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 500 && sales <= 1_000)
            {
                sales *= 0.08;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 1_000 && sales <= 10_000)
            {
                sales *= 0.12;
                Console.WriteLine($"{sales:F2}");
            }
            else if (sales > 10_000)
            {
                sales *= 0.145;
                Console.WriteLine($"{sales:F2}");
            }
            else
            {
                Console.WriteLine("error");
            }
        }
        else
        {
            Console.WriteLine("error");
        }
    }
}
}
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