Advertisement
kabalsky

04. Best Plane Tickets

Oct 14th, 2019
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BestPlaneTicket
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool flight = true;
  10.             double sum = 0;
  11.             int hour = 0;
  12.             int min = 0;
  13.             int newtime= 0;
  14.             string newno = " ";
  15.             double newprice = 0;
  16.            
  17.             for (int i = 1;flight == true; i++)
  18.             {
  19.                 string flightno = Console.ReadLine();
  20.                 if (flightno == "End")
  21.                 {
  22.                     break;
  23.                 }
  24.                 double flightprice = double.Parse(Console.ReadLine());
  25.                 int flightduration = int.Parse(Console.ReadLine());
  26.                 if (newtime == 0)
  27.                 {
  28.                     newtime += flightduration;
  29.                 }
  30.                 if (flightduration <= newtime)
  31.                 {
  32.                     newtime = flightduration;
  33.                     newprice = flightprice;
  34.                     newno = flightno;
  35.                     sum = flightprice * 1.96;
  36.                     hour = flightduration / 60;
  37.                     min = Math.Abs(hour * 60 - flightduration);
  38.                 }
  39.             }
  40.                     Console.WriteLine($"Ticket found for flight {newno} costs {sum:F2} leva with {hour}h {min}m stay");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement