Advertisement
bayangarkov

SoftUniAirline

Apr 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09_SoftuniAirline
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             var numberOfFlights = int.Parse(Console.ReadLine());
  14.  
  15.             var overallProfit = 0.0;
  16.             var averageProfit = 0.0;
  17.  
  18.             for (int i = 0; i < numberOfFlights; i++)
  19.             {
  20.                 var adultsCount = long.Parse(Console.ReadLine());
  21.                 var adultsTicketPrice = double.Parse(Console.ReadLine());
  22.                 var youngCount = long.Parse(Console.ReadLine());
  23.                 var youngTicketsPrice = double.Parse(Console.ReadLine());
  24.                 var fuelPricePerHour = double.Parse(Console.ReadLine());
  25.                 var fuelConsumptionPerHour = double.Parse(Console.ReadLine());
  26.                 var flightDuration = int.Parse(Console.ReadLine());
  27.  
  28.                 var income = (adultsCount * adultsTicketPrice) + (youngCount * youngTicketsPrice);
  29.                 var expenses = flightDuration * fuelConsumptionPerHour * fuelPricePerHour;
  30.  
  31.                 var difference = Math.Abs(expenses - income);
  32.                
  33.  
  34.                 if (expenses > income)
  35.                 {
  36.                     overallProfit = overallProfit - difference;
  37.                     Console.WriteLine($"We’ve got to sell more tickets! We’ve lost {difference:f3}$.");
  38.                 }
  39.                 else
  40.                 {
  41.                     overallProfit = overallProfit + difference;
  42.                     Console.WriteLine($"You are ahead with {difference:f3}$.");
  43.                 }
  44.  
  45.             }
  46.  
  47.             averageProfit = overallProfit / numberOfFlights;
  48.  
  49.             Console.WriteLine($"Overall profit -> {overallProfit:f3}$.");
  50.             Console.WriteLine($"Average profit -> {averageProfit:f3}$.");
  51.  
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement