Advertisement
jordan3900

Untitled

Jul 26th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 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 _01.SoftUniAirlines
  8. {
  9. class softUniArilines
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. //• adult passengers count
  15. //• adult ticket price
  16. //• youth passengers count
  17. //• youth ticket price
  18. //• fuel price per hour
  19. //• fuel consumption per hour
  20. //• flight duration
  21.  
  22. int cnt = int.Parse(Console.ReadLine());
  23.  
  24. decimal lost = 0;
  25. decimal profit = 0;
  26. for (int i = 0; i <cnt; i++)
  27. {
  28. long adultPassengers = long.Parse(Console.ReadLine());
  29. decimal adultTicketPrice = decimal.Parse(Console.ReadLine());
  30. long youthPassengers = long.Parse(Console.ReadLine());
  31. decimal youthTicket = decimal.Parse(Console.ReadLine());
  32. decimal fuelPrice = decimal.Parse(Console.ReadLine());
  33. decimal fuelConsumptioPerH = decimal.Parse(Console.ReadLine());
  34. int flightDuration = int.Parse(Console.ReadLine());
  35.  
  36. decimal totalTickets = (adultPassengers * adultTicketPrice) + (youthPassengers * youthTicket);
  37. decimal priceOfFlight = fuelConsumptioPerH * flightDuration * fuelPrice;
  38.  
  39. if (totalTickets>=priceOfFlight)
  40. {
  41. profit += totalTickets - priceOfFlight;
  42. Console.WriteLine($"You are ahead with {profit:f3}$.");
  43.  
  44. }
  45. else
  46. {
  47. lost +=totalTickets- priceOfFlight ;
  48. Console.WriteLine($"We've got to sell more tickets! We've lost {lost:f3}$.");
  49.  
  50. }
  51. }
  52.  
  53. decimal overall = profit + lost;
  54. Console.WriteLine($"Overall profit -> { overall:f3}$.");
  55. Console.WriteLine($"Average profit -> { overall / cnt:f3}$.");
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement