SoftUni AirLine
Един от тестовете ми гърми, ако някои може да ми помогне, ще съм благодарен :)
var n = double.Parse(Console.ReadLine());
double OverAll = 0.0;
double Average = 0.0;
for (int i = 0; i < n; i++)
{
var AdultPassengersCount = double.Parse(Console.ReadLine());
var AdultTicketPrice = double.Parse(Console.ReadLine());
var YouthPassengersCount = double.Parse(Console.ReadLine());
var YouthTicketPrice = double.Parse(Console.ReadLine());
var FuelPricePerHour = double.Parse(Console.ReadLine());
var FuelConsumptionPerHour = double.Parse(Console.ReadLine());
var FlightDuration = double.Parse(Console.ReadLine());
double Income = (AdultPassengersCount * AdultTicketPrice) + (YouthPassengersCount * YouthTicketPrice);
double expense = FlightDuration * FuelConsumptionPerHour * FuelPricePerHour;
double diff = Income - expense;
OverAll += diff;
if (Income >= expense)
Console.WriteLine($"You are ahead with {diff,0:f3}$.");
if(Income < expense)
Console.WriteLine($"We've got to sell more tickets! We've lost {diff,0:f3}$.");
}
Average = (double)(OverAll / n);
Console.WriteLine($"Overall profit -> {OverAll,0:f3}$.");
Console.WriteLine($"Average profit -> {Average, 0:f3}$.");
Пробвах и пак не става....
Забравих да уточня, че някои трябва да да decimal, а други int. В условието на задачата е уточнено точно коя променлива какъв вид трябва да бъде.
Поиграх си малко с твоя код и го докарах до 100/100.
var n = int.Parse(Console.ReadLine());
decimal OverAll = 0.0m;
decimal Average = 0.0m;
for (int i = 0; i < n; i++)
{
var AdultPassengersCount = int.Parse(Console.ReadLine());
var AdultTicketPrice = decimal.Parse(Console.ReadLine());
var YouthPassengersCount = int.Parse(Console.ReadLine());
var YouthTicketPrice = decimal.Parse(Console.ReadLine());
var FuelPricePerHour = double.Parse(Console.ReadLine());
var FuelConsumptionPerHour = double.Parse(Console.ReadLine());
var FlightDuration = double.Parse(Console.ReadLine());
decimal Income = (AdultPassengersCount * AdultTicketPrice) + (YouthPassengersCount * YouthTicketPrice);
decimal expense = (decimal)(FlightDuration * FuelConsumptionPerHour * FuelPricePerHour);
decimal diff = Income - expense;
OverAll += diff;
if (Income >= expense)
Console.WriteLine($"You are ahead with {diff,0:f3}$.");
if (Income < expense)
Console.WriteLine($"We've got to sell more tickets! We've lost {diff,0:f3}$.");
}
Average =OverAll / n;
Console.WriteLine($"Overall profit -> {OverAll,0:f3}$.");
Console.WriteLine($"Average profit -> {Average,0:f3}$.");
Много ти брагодаря :)