Advertisement
Deiancom

Best Plane Tickets

Jul 29th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package EXAM;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Best_Plane_Tickets_04 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String ticketNumber = "";
  9.         double price = 0;
  10.         int minutesWaiting = 100000;
  11.         String input = scanner.nextLine();
  12.         while (!input.equals("End")) {
  13.             int ticketPrice = Integer.parseInt(scanner.nextLine());
  14.             int time = Integer.parseInt(scanner.nextLine());
  15.             if (minutesWaiting > time) {
  16.                 ticketNumber = input;
  17.                 price = ticketPrice;
  18.                 minutesWaiting = time;
  19.             }
  20.             input = scanner.nextLine();
  21.         }
  22.         price *= 1.96;
  23.         int hours = minutesWaiting / 60;
  24.         int minutes = minutesWaiting % 60;
  25.  
  26.         System.out.printf("Ticket found for flight %s costs %.2f leva with %dh %dm stay",ticketNumber,price,hours,minutes);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement