Advertisement
fbinnzhivko

Untitled

Jun 10th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         decimal[] income = new decimal[n];
  9.         decimal[] expences = new decimal[n];
  10.         decimal[] profit = new decimal[n];
  11.  
  12.         for (int i = 0; i < n; i++)
  13.         {
  14.             int adultsCount = int.Parse(Console.ReadLine());
  15.             decimal adultsPrice = decimal.Parse(Console.ReadLine());
  16.             int youthsCount = int.Parse(Console.ReadLine());
  17.             decimal youthsPrice = decimal.Parse(Console.ReadLine());
  18.             decimal fuelPrice = decimal.Parse(Console.ReadLine());
  19.             decimal fuelConsum = decimal.Parse(Console.ReadLine());
  20.             int flightDur = int.Parse(Console.ReadLine());
  21.  
  22.             income[i] = adultsCount * adultsPrice + youthsCount * youthsPrice;
  23.             expences[i] = flightDur * fuelConsum * fuelPrice;
  24.             profit[i] = income[i] - expences[i];
  25.  
  26.             if (profit[i] < 0)
  27.             {
  28.                 Console.WriteLine("We've got to sell more tickets! We've lost {0:F3}$.", profit[i]);
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("You are ahead with {0:f3}$.", profit[i]);
  33.             }
  34.         }
  35.         decimal overall = profit.Sum();
  36.         decimal average = profit.Average();
  37.         Console.WriteLine("Overall profit -> {0:F3}$.", overall);
  38.         Console.WriteLine("Average profit -> {0:F3}$.", average);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement