Trade Commissions-94/100- не мога да си открия грешката
using System;
namespace TradeCommissions
{
class Program
{
static void Main()
{
string town = Console.ReadLine();
double salesVolume = double.Parse(Console.ReadLine());
double commission = 0;
bool isValid = (salesVolume >= 0) && (town == "Sofia" || town == "Varna" || town == "Plovdiv");
if (salesVolume >= 0 && salesVolume <= 500)
{
if (town == "Sofia")
{
commission = salesVolume * 0.05;
}
else if (town== "Varna")
{
commission = salesVolume * 0.045;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.055;
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume> 500 && salesVolume <= 1000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.07;
}
else if (town == "Varna")
{
commission = salesVolume * 0.075;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.08;
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume > 1000 && salesVolume <= 10000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.08;
}
else if (town == "Varna")
{
commission = salesVolume * 0.10;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.12;
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume > 10000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.12;
}
else if (town == "Varna")
{
commission = salesVolume * 0.13;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.145;
}
Console.WriteLine($"{commission:f2}");
}
if (!isValid)
{
Console.WriteLine("error");
}
}
}
}
Размених ги и така не става
Дай си кода пак, да не се е объркало нещо.
using System;
namespace TradeCommissions
{
class Program
{
static void Main()
{
string town = Console.ReadLine();
double salesVolume = double.Parse(Console.ReadLine());
double commission = 0;
bool isValid = (salesVolume>= 0) && (town == "Sofia" || town == "Varna" || town == "Plovdiv");
if (salesVolume >= 0 && salesVolume <= 500)
{
if (town == "Sofia")
{
commission = salesVolume * 0.05;
}
else if (town== "Varna")
{
commission = salesVolume * 0.045;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.055;
}
if (!isValid)
{
Console.WriteLine("error");
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume> 500 && salesVolume <= 1000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.07;
}
else if (town == "Varna")
{
commission = salesVolume * 0.075;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.08;
}
if (!isValid)
{
Console.WriteLine("error");
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume > 1000 && salesVolume <= 10000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.08;
}
else if (town == "Varna")
{
commission = salesVolume * 0.10;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.12;
}
if (!isValid)
{
Console.WriteLine("error");
}
Console.WriteLine($"{commission:f2}");
}
else if (salesVolume > 10000)
{
if (town == "Sofia")
{
commission = salesVolume * 0.12;
}
else if (town == "Varna")
{
commission = salesVolume * 0.13;
}
else if (town == "Plovdiv")
{
commission = salesVolume * 0.145;
}
if (!isValid)
{
Console.WriteLine("error");
}
Console.WriteLine($"{commission:f2}");
}
if (!isValid)
{
Console.WriteLine("error");
}
}
}
}
Махни проверките за валидност при 0 д0 500; от 500 до 1000 и т.н.
Остави накрая проверката и печата
if (!isValid)
{
Console.WriteLine("error");
}
else
{
Console.WriteLine($"{commission:f2}");
}