Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.6 kB
0
Indexable
Never
string nameOfCity = Console.ReadLine();
double volumeOfSales = double.Parse(Console.ReadLine());
bool error = false;
double commissionRate = 0;

switch (nameOfCity)
{
    case "Sofia":
        if (volumeOfSales > 0 && volumeOfSales <= 500)
            commissionRate = 0.05;
        else if (volumeOfSales <= 1000)
            commissionRate = 0.07;
        else if (volumeOfSales <= 10000)
            commissionRate = 0.08;
        else if(volumeOfSales > 10000)
            commissionRate = 0.12;
        else
            error = true;
        break;
    case "Varna":
        if (volumeOfSales > 0 && volumeOfSales <= 500)
            commissionRate = 0.045;
        else if (volumeOfSales <= 1000)
            commissionRate = 0.075;
        else if (volumeOfSales <= 10000)
            commissionRate = 0.1;
        else if (volumeOfSales > 10000)
            commissionRate = 0.13;
        else
            error = true;
        break;
    case "Plovdiv":
        if (volumeOfSales <= 500)
            commissionRate = 0.055;
        else if (volumeOfSales <= 1000)
            commissionRate = 0.08;
        else if (volumeOfSales <= 10000)
            commissionRate = 0.12;
        else if (volumeOfSales > 10000)
            commissionRate = 0.145;
        else
            error = true;
        break;
    default:
        error = true;
        break;

}
double commission = volumeOfSales * commissionRate;
if (volumeOfSales < 0)
    error = true;
if (!error)
    Console.WriteLine($"{commission:f2}");
else
    Console.WriteLine("error");
Leave a Comment