kvadrat4o

SUAirline

Jul 8th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 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. using System.Numerics;
  7.  
  8. namespace SUAirline
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             //SortedDictionary<long,Dictionary<long,long>> flights = new SortedDictionary<long, Dictionary<long, long>>();
  16.             Dictionary<long, double> flights = new Dictionary<long, double>();
  17.             var adultPasCount = 0L;
  18.             var adultTicketPrice = 0L;
  19.             var youhtPasCount = 0L;
  20.             var youthTicketPrice = 0L;
  21.             var fuelPricePerHour = 0.00;
  22.             var fuelConsuPerHour = 0.00;
  23.             var flightDuration = 0;
  24.             long tickets = 0;
  25.             double expenses = 0.00;
  26.             double total = 0.00;
  27.             for (int i = 0; i < n; i++)
  28.             {
  29.                 adultPasCount = long.Parse(Console.ReadLine());
  30.                 adultTicketPrice = long.Parse(Console.ReadLine());
  31.                 youhtPasCount = long.Parse(Console.ReadLine());
  32.                 youthTicketPrice = long.Parse(Console.ReadLine());
  33.                 fuelPricePerHour = double.Parse(Console.ReadLine());
  34.                 fuelConsuPerHour = double.Parse(Console.ReadLine());
  35.                 flightDuration = int.Parse(Console.ReadLine());
  36.                 tickets = (long)(adultPasCount * adultTicketPrice) + (youhtPasCount * youthTicketPrice);
  37.                 expenses = ((double)flightDuration * fuelConsuPerHour * fuelPricePerHour);
  38.                 total = tickets - expenses;
  39.                 //flights[tickets] = new Dictionary<long, long>();
  40.                 flights.Add(tickets,expenses);
  41.             }
  42.             foreach (var flight in flights)
  43.             {
  44.                 if (flight.Key >= flight.Value)
  45.                 {
  46.                     Console.WriteLine("You are ahead with {0:F3}$.", Math.Abs(flight.Key - flight.Value));
  47.                 }
  48.                 else
  49.                 {
  50.                     Console.WriteLine("We've got to sell more tickets! We've lost {0:F3}$.", flight.Key - flight.Value);
  51.                 }
  52.             }
  53.             double  totalProfit = flights.Keys.Sum() - flights.Values.Sum();
  54.             double avgProfit = totalProfit / n;
  55.             Console.WriteLine("Overall profit -> {0:F3}$.\nAverage profit -> {1:F3}$.", totalProfit, avgProfit);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment