Advertisement
braveheart1989

SoftUniAirline

Jun 11th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 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.SoftUniAirline
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int n = int.Parse(Console.ReadLine());
  15.             int adultPassengersCount = 0;
  16.             decimal adultticketPrice = 0;
  17.             int youthPassengersCount = 0;
  18.             decimal youthTicketPrice = 0;
  19.             decimal fuelPricePerHours = 0;
  20.             decimal fuelConsumptionPerHour = 0;
  21.             int flightDuration = 0;
  22.  
  23.             decimal income = 0;
  24.             decimal expenses = 0;
  25.             decimal profit = 0;
  26.             decimal totalIncome = 0;
  27.             decimal averageIncome = 0;
  28.             //(adult passengers count * adult ticket price) + (youth passengers count * youth ticket price)
  29.             //(flight duration * (fuel consumption * fuel price))
  30.             for (int i = 0; i < n; i++)
  31.             {
  32.                 adultPassengersCount = int.Parse(Console.ReadLine());
  33.                 adultticketPrice = decimal.Parse(Console.ReadLine());
  34.                 youthPassengersCount = int.Parse(Console.ReadLine());
  35.                 youthTicketPrice = decimal.Parse(Console.ReadLine());
  36.                 fuelPricePerHours = decimal.Parse(Console.ReadLine());
  37.                 fuelConsumptionPerHour = decimal.Parse(Console.ReadLine());
  38.                 flightDuration = int.Parse(Console.ReadLine());
  39.  
  40.                 income = ((decimal)adultPassengersCount*adultticketPrice) + (youthPassengersCount*youthTicketPrice);
  41.                 expenses = flightDuration*(fuelConsumptionPerHour*fuelPricePerHours);
  42.                 profit = income - expenses;
  43.                 if (income>=expenses)
  44.                 {
  45.                     Console.WriteLine("You are ahead with {0:F3}$.",profit);
  46.                 }
  47.                else if (expenses>income)
  48.                {
  49.                    Console.WriteLine("We've got to sell more tickets! We've lost {0:f3}$.",profit);
  50.                }
  51.                 totalIncome += profit;
  52.             }
  53.  
  54.             Console.WriteLine("Overall profit -> {0:F3}$.",totalIncome);
  55.             Console.WriteLine("Average profit -> {0:F3}$.", totalIncome/n);
  56.  
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement