Advertisement
fbinnzhivko

Untitled

Jun 10th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         decimal numberFlights = decimal.Parse(Console.ReadLine());
  7.  
  8.         decimal totalProfit = 0;
  9.  
  10.         for (int i = 0; i < numberFlights; i++)
  11.         {
  12.             decimal adultPassCount = decimal.Parse(Console.ReadLine());
  13.             decimal adultTicketCount = decimal.Parse(Console.ReadLine());
  14.  
  15.             decimal youthPassCount = decimal.Parse(Console.ReadLine());
  16.             decimal youthTicketCount = decimal.Parse(Console.ReadLine());
  17.  
  18.             decimal fuelPriceperHour = decimal.Parse(Console.ReadLine());
  19.             decimal fuelConsumptionPerHour = decimal.Parse(Console.ReadLine());
  20.             decimal flightDuration = decimal.Parse(Console.ReadLine());
  21.  
  22.  
  23.             decimal income = adultPassCount * adultTicketCount + youthTicketCount * youthPassCount;
  24.             decimal expenses = flightDuration * fuelConsumptionPerHour * fuelPriceperHour;
  25.  
  26.             decimal profit = income - expenses;
  27.  
  28.             if (profit >= 0)
  29.             {
  30.                 Console.WriteLine("You are ahead with {0:f3}$.", profit);
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("We've got to sell more tickets! We've lost -{0:f3}$.", expenses - income);
  35.             }
  36.             totalProfit = totalProfit + profit;
  37.  
  38.         }
  39.         Console.WriteLine("Overall profit -> {0:f3}$.", totalProfit);
  40.         Console.WriteLine("Average profit -> {0:f3}$.", totalProfit / numberFlights);
  41.  
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement