06. Fishing Boat --Проблем със задчата.
using System;
namespace ConsoleApp40
{
class Program
{
static void Main(string[] args)
{
var budget = double.Parse(Console.ReadLine());
var seaseons = Console.ReadLine();
var countFisherman = double.Parse(Console.ReadLine());
var priceForRentShip = 0.00;
switch (seaseons)
{
case "Spring":
priceForRentShip = 3000;
break;
case "Summer":
priceForRentShip = 4200;
break;
case "Autumn":
priceForRentShip = 4200;
break;
case "Winter":
priceForRentShip = 2600;
break;
}
var discount = 0.00;
if (countFisherman <= 6)
{
discount = 0.10;
}
else if (countFisherman >=7 && countFisherman <=11)
{
discount = 0.15;
}
else if (countFisherman >= 12)
{
discount = 0.25;
}
var resultMinus = priceForRentShip * discount;
var result = priceForRentShip - resultMinus;
if (result % 2 == 0 && seaseons != "Autumn")
{
result = priceForRentShip - (priceForRentShip * discount * 0.05);
}
if (result <= budget)
{
Console.WriteLine($"Yes! You have {result - budget :f2} leva left.");
}
else if (result > budget)
{
Console.WriteLine($"Not enough money!You need {result - budget:f2} leva.");
}
}
}
}
Това ми е кода грешката ми май е в изчислението.
var resultMinus = priceForRentShip * discount;
var result = priceForRentShip - resultMinus;
var result трябва да е 3570 като се въведе
3000
Summer
11
priceForRentShip - resultMinus е равно на 3570 но result ми дава 4168.5