Programming Fundamentals Sample Exam II
Блокирах на най-простата задача "Soft Uni Airline". Тестовете ми излизат, обаче дава 20 точки. ако някой може да ми пососчи грешката?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sample_exam
{
class Program
{
static void Main(string[] args)
{
var flights = decimal.Parse(Console.ReadLine());
decimal prophitMoney = 0;
decimal lostMoney = 0;
decimal overall = 0;
for (int i = 1; i <= flights; i++)
{
var adults = decimal.Parse(Console.ReadLine());
var adultTicketPrice = decimal.Parse(Console.ReadLine());
var kids = decimal.Parse(Console.ReadLine());
var kidsTicketPrice = decimal.Parse(Console.ReadLine());
var fuelPrice = decimal.Parse(Console.ReadLine());
var fuelConsumption = decimal.Parse(Console.ReadLine());
var flightDuration = decimal.Parse(Console.ReadLine());
decimal expences = flightDuration * fuelConsumption * fuelPrice;
decimal income = (adults * adultTicketPrice) + (kids * kidsTicketPrice);
decimal total = income - expences;
if (total < 0)
{
lostMoney += total;
}
else
{
prophitMoney += total;
}
}
overall = prophitMoney + lostMoney;
if (lostMoney < 0)
Console.WriteLine("We've got to sell more tickets! We've lost {0:f3}$." , lostMoney);
if (prophitMoney > 0 && overall > 0 )
{
Console.WriteLine("You are ahead with {0:f3}$.", prophitMoney);
Console.WriteLine("Overall profit -> {0:f3}$.", overall);
Console.WriteLine("Average profit -> {0:f3}$.", overall / flights);
}
}
}
}