Advertisement
rado84

AirLines

Jun 13th, 2016
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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 SoftUniAirline
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double flights = double.Parse(Console.ReadLine());
  14.  
  15. for (int i = 0; i < flights; i++)
  16. {
  17. int adultPassCount = int.Parse(Console.ReadLine());
  18. int youngPassCount = int.Parse(Console.ReadLine());
  19. double adultTicketPrice = double.Parse(Console.ReadLine());
  20. double youngTicketPrice = double.Parse(Console.ReadLine());
  21. double fuelPricePerHour = double.Parse(Console.ReadLine());
  22. double fuelConsPerHour = double.Parse(Console.ReadLine());
  23.  
  24. //income & outcome
  25. double income = (adultPassCount * adultTicketPrice) + (youngPassCount * youngTicketPrice);
  26. double outcome = fuelPricePerHour * fuelConsPerHour * flights;
  27.  
  28. //profit
  29. double profit = income - outcome;
  30. double avgProfit = profit / flights;
  31.  
  32. if (profit > 0)
  33. {
  34. Console.WriteLine("You're ahead with {0:f3}", profit + "$.");
  35. }
  36.  
  37. else if (profit <= 0)
  38. {
  39. Console.WriteLine("We've got to sell more tickets! We've lost {0:f3}", profit + "$.");
  40. }
  41.  
  42. Console.WriteLine("Overall profit -> {0:f3}", profit + "$.");
  43. Console.WriteLine("Average profit -> {0:f3}", avgProfit + "$.");
  44.  
  45. }
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement