Guest User

SoftUni-Airlines-v2

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