Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _09_SoftuniAirline
- {
- class Program
- {
- static void Main()
- {
- var numberOfFlights = int.Parse(Console.ReadLine());
- var overallProfit = 0.0;
- var averageProfit = 0.0;
- for (int i = 0; i < numberOfFlights; i++)
- {
- var adultsCount = long.Parse(Console.ReadLine());
- var adultsTicketPrice = double.Parse(Console.ReadLine());
- var youngCount = long.Parse(Console.ReadLine());
- var youngTicketsPrice = double.Parse(Console.ReadLine());
- var fuelPricePerHour = double.Parse(Console.ReadLine());
- var fuelConsumptionPerHour = double.Parse(Console.ReadLine());
- var flightDuration = int.Parse(Console.ReadLine());
- var income = (adultsCount * adultsTicketPrice) + (youngCount * youngTicketsPrice);
- var expenses = flightDuration * fuelConsumptionPerHour * fuelPricePerHour;
- var difference = Math.Abs(expenses - income);
- if (expenses > income)
- {
- overallProfit = overallProfit - difference;
- Console.WriteLine($"We’ve got to sell more tickets! We’ve lost {difference:f3}$.");
- }
- else
- {
- overallProfit = overallProfit + difference;
- Console.WriteLine($"You are ahead with {difference:f3}$.");
- }
- }
- averageProfit = overallProfit / numberOfFlights;
- Console.WriteLine($"Overall profit -> {overallProfit:f3}$.");
- Console.WriteLine($"Average profit -> {averageProfit:f3}$.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement