Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BestPlaneTicket
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool flight = true;
- double sum = 0;
- int hour = 0;
- int min = 0;
- int minFlightDuration = 500; // Присвояваме максималните минути престой. Смених и името на променливата
- string flightNumber = "";
- //double newprice = 0; // Няма смисъл от тази променлива
- string currentFlightNumber = ""; // Или string currentFlightNumber = string.Empty;
- for (int i = 1; flight == true; i++) // Може да се ползва и while(true) или while((flightNumber = Console.ReadLine()) != "End") (Тогава нещата от ред 20 до ред 24 са излишни.)
- {
- currentFlightNumber = Console.ReadLine();
- if (currentFlightNumber == "End")
- {
- break;
- }
- double flightPrice = double.Parse(Console.ReadLine());
- int currentFlightDuration = int.Parse(Console.ReadLine());
- if (currentFlightDuration < minFlightDuration)
- {
- minFlightDuration = currentFlightDuration;
- //newprice = flightprice;
- flightNumber = currentFlightNumber;
- sum = flightPrice * 1.96;
- hour = currentFlightDuration / 60;
- min = Math.Abs(hour * 60 - currentFlightDuration); // Може да се сметне и currentFlightDuration % 60
- }
- }
- Console.WriteLine($"Ticket found for flight {flightNumber} costs {sum:F2} leva with {hour}h {min}m stay");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement