Advertisement
YavorJS

SoftUni Airline 100%

Sep 13th, 2016
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 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 SoftUni_Airline
  8. {
  9. class Airline
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numberOfFlights = int.Parse(Console.ReadLine());
  14. int adultPassengersCount = 0;
  15. decimal adultTicketPrice = 0;
  16. int youthPassengersCount = 0;
  17. decimal youthTicketPrice = 0;
  18. decimal fuelPricePerHour = 0;
  19. decimal fuelConsumptionPerHour = 0;
  20. int flightDuration = 0;
  21.  
  22. decimal income = 0;
  23. decimal expenses = 0;
  24. decimal profit = 0;
  25. decimal overallProfit = 0;
  26. decimal averageProfit = 0;
  27.  
  28. for (int flight = 0; flight < numberOfFlights; flight++)
  29. {
  30. adultPassengersCount = int.Parse(Console.ReadLine());
  31. adultTicketPrice = decimal.Parse(Console.ReadLine());
  32. youthPassengersCount = int.Parse(Console.ReadLine());
  33. youthTicketPrice = decimal.Parse(Console.ReadLine());
  34. fuelPricePerHour = decimal.Parse(Console.ReadLine());
  35. fuelConsumptionPerHour = decimal.Parse(Console.ReadLine());
  36. flightDuration = int.Parse(Console.ReadLine());
  37. income = (adultPassengersCount * adultTicketPrice) + (youthPassengersCount * youthTicketPrice);
  38. expenses = flightDuration * fuelConsumptionPerHour * fuelPricePerHour;
  39. profit = income - expenses;
  40. overallProfit += profit;
  41. if (profit >= 0)
  42. {
  43. Console.WriteLine($"You are ahead with {profit:f3}$.");
  44. }
  45. else
  46. {
  47. Console.WriteLine($"We've got to sell more tickets! We've lost {profit:f3}$.");
  48. }
  49. }//end of for
  50. averageProfit = overallProfit / numberOfFlights;
  51. Console.WriteLine($"Overall profit -> {overallProfit:f3}$.");
  52. Console.WriteLine($"Average profit -> {averageProfit:f3}$.");
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement