Advertisement
aggressiveviking

Untitled

Feb 24th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.BestPlaneTickets
  4. {
  5.     class BestPlaneTickets
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string numTicket = Console.ReadLine();
  10.  
  11.             double leva = 1.96;
  12.            
  13.             double lowestStay = double.MaxValue;
  14.             double bestPrice = double.MinValue;
  15.             string bestTicket = "";
  16.  
  17.             while (numTicket != "End")
  18.             {
  19.                 double price = double.Parse(Console.ReadLine());
  20.                 double minutesStay = double.Parse(Console.ReadLine());
  21.  
  22.                 price = price * leva;
  23.  
  24.                 if (minutesStay < lowestStay)
  25.                 {
  26.                     bestPrice = price;
  27.                     bestTicket = numTicket;
  28.                     lowestStay = minutesStay;
  29.                 }
  30.  
  31.                 numTicket = Console.ReadLine();
  32.             }
  33.  
  34.             Console.WriteLine($"Ticket found for flight {bestTicket} costs {bestPrice:F2} leva with {lowestStay / 60}h {lowestStay % 60}m stay");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement