Advertisement
Guest User

BabaTincheAirlines

a guest
Mar 8th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class BabaTincheAirlines
  5. {
  6.     // constant values
  7.     const int fCPassenger = 12;
  8.     const int fCTicket = 7000;
  9.  
  10.     const int bCPassenger = 28;
  11.     const int bCTicket = 3500;
  12.  
  13.     const int eCPassenger = 50;
  14.     const int eCTicket = 1000;
  15.  
  16.     static void Main()
  17.     {
  18.         // 233160
  19.         int maxIncome = (int)(fCPassenger * fCTicket + fCPassenger * (fCTicket * 0.005)) + (int)(bCPassenger * bCTicket + bCPassenger * (bCTicket * 0.005)) + (int)(eCPassenger * eCTicket + eCPassenger * (eCTicket * 0.005));
  20.  
  21.         // input
  22.         string first = Console.ReadLine();
  23.         string business = Console.ReadLine();
  24.         string economy = Console.ReadLine();
  25.  
  26.         // calculate and print actual profit
  27.         int actualProfit = FirstClProfit(first) + BusinessClProfit(business) + EconomyClProfit(economy);
  28.         Console.WriteLine(actualProfit);
  29.  
  30.         // print difference between maximal and actual profit
  31.         Console.WriteLine(maxIncome - actualProfit);
  32.     }
  33.  
  34.     static int FirstClProfit(string first)
  35.     {
  36.         // splitting the input string into a number arrray
  37.         int[] firstClass = first.Split(' ').Select(int.Parse).ToArray();
  38.  
  39.         // using the const values above and the input arra values in this actual profit formula for first class
  40.         int profit = (firstClass[0] - firstClass[1]) * fCTicket + (int)(firstClass[1] * (fCTicket * 0.3)) + (int)(firstClass[2] * (fCTicket * 0.005));
  41.  
  42.         return profit;
  43.     }
  44.  
  45.     static int BusinessClProfit(string business)
  46.     {
  47.         // splitting the input string into a number arrray
  48.         int[] businessClass = business.Split(' ').Select(int.Parse).ToArray();
  49.  
  50.         // using the const values above and the input arra values in this actual profit formula for business class
  51.         int profit = (businessClass[0] - businessClass[1]) * bCTicket + (int)(businessClass[1] * (bCTicket * 0.3)) + (int)(businessClass[2] * (bCTicket * 0.005));
  52.  
  53.         return profit;
  54.     }
  55.  
  56.     static int EconomyClProfit(string economy)
  57.     {
  58.         // splitting the input string into a number arrray
  59.         int[] economyClass = economy.Split(' ').Select(int.Parse).ToArray();
  60.  
  61.         // using the const values above and the input arra values in this actual profit formula for economy class
  62.         int profit = (economyClass[0] - economyClass[1]) * eCTicket + (int)(economyClass[1] * (eCTicket * 0.3)) + (int)(economyClass[2] * (eCTicket * 0.005));
  63.  
  64.         return profit;
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement