Advertisement
tutzy

Baba Tinche Airlines

Apr 2nd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. //•   First Class which accommodates 12 passengers. The ticket price is $7000.
  2. //•   Business Class which accommodates 28 passengers. The ticket price is $3500.
  3. //•   Economy Class which accommodates 50 passengers. The ticket price is $1000.
  4.  
  5. //Please note that some passengers are Frequent Flyers and their tickets are 70% off ($1000 ticket will cost $300). Also some passengers purchase a meal on the flight, which costs 0.5% of the ticket price for the travel class they are in. Please help Baba Tinche calculate her income and calculate the difference between her income and the maximum possible income (the maximum possible income being all seats taken, no Frequent Flyers and everyone purchasing meals). You will be given the number of passengers for each class, the number of passengers who are Frequent Flyers in that class, and the number of passengers who purchase a meal in that class.
  6.  
  7. //Input
  8. //The input data should be read from the console. It consists of exactly 3 lines:
  9. //•   The first line holds the number of all passengers in First Class
  10. //•   The second line holds the number of all passengers in Business Class
  11. //•   The third line holds the number of all passengers in Economy Class
  12. //•   The second and third number on all lines will be the number of Frequent Flyers and the number of passengers who will purchase a meal in the given class.
  13. //The input data will always be valid and in the format described. There is no need to check it explicitly.
  14.  
  15. //Output
  16. //The output should be printed on the console. It should consist of exactly 2 lines.
  17. //•   The first line will  hold Baba Tinche’s income cast to an integer
  18. //•   The second line holding the difference between the maximum possible profit and baba Tinche’s actual profit cast to an integer
  19.  
  20.  
  21.  
  22. using System;
  23.  
  24. class Program
  25. {
  26.     static void Main()
  27.     {
  28.         string[] firstClass=Console.ReadLine().Split(' ');
  29.         string[] secondClass = Console.ReadLine().Split(' ');
  30.         string[] thirdClass = Console.ReadLine().Split(' ');
  31.         double firstSum=0;
  32.         double secondSum=0;
  33.         double thirdSum=0;
  34.         double max = 233160;
  35.         for (int i = 0; i < firstClass.Length; i++)
  36.         {
  37.             int a = int.Parse(firstClass[0]);
  38.             int b = int.Parse(firstClass[1]);
  39.             int c = int.Parse(firstClass[2]);
  40.             double firsClassSum=((a-b)*7000)+(b*(7000-(7000*0.7)))+(c*((7000*0.5)/100));//37170.0
  41.             firstSum=firsClassSum;
  42.         }
  43.         for (int i = 0; i < secondClass.Length; i++)
  44.         {
  45.             int a = int.Parse(secondClass[0]);
  46.             int b = int.Parse(secondClass[1]);
  47.             int c = int.Parse(secondClass[2]);
  48.             double secondClassSum = ((a - b) * 3500) + (b * (3500 - (3500 * 0.7))) + (c * ((3500 * 0.5) / 100));//
  49.             secondSum=secondClassSum;
  50.         }
  51.         for (int i = 0; i < thirdClass.Length; i++)
  52.         {
  53.             int a = int.Parse(thirdClass[0]);
  54.             int b = int.Parse(thirdClass[1]);
  55.             int c = int.Parse(thirdClass[2]);
  56.             double thirdClassSum = ((a - b) * 1000) + (b * (1000 - (1000 * 0.7))) + (c * ((1000 * 0.5) / 100));//
  57.             thirdSum=thirdClassSum;
  58.         }
  59.         double income = firstSum + secondSum + thirdSum;
  60.         double diff = max - income;
  61.         Console.WriteLine((int)income);
  62.         Console.WriteLine((int)Math.Ceiling(diff));
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement