Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package EXAM;
- import java.util.Scanner;
- public class Best_Plane_Tickets_04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String ticketNumber = "";
- double price = 0;
- int minutesWaiting = 100000;
- String input = scanner.nextLine();
- while (!input.equals("End")) {
- int ticketPrice = Integer.parseInt(scanner.nextLine());
- int time = Integer.parseInt(scanner.nextLine());
- if (minutesWaiting > time) {
- ticketNumber = input;
- price = ticketPrice;
- minutesWaiting = time;
- }
- input = scanner.nextLine();
- }
- price *= 1.96;
- int hours = minutesWaiting / 60;
- int minutes = minutesWaiting % 60;
- System.out.printf("Ticket found for flight %s costs %.2f leva with %dh %dm stay",ticketNumber,price,hours,minutes);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement