Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class skyHigh {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //inputs
- String flightNumber[] = {"AF 1975", "AY 2003", "TG 1999", "SQ 1010", "PF 2606", "DY 2009", "JL 1996", "US 1950", "BA 2505", "LH 1998"};
- int departureTime[] = {1710, 1432, 1500, 1807, 1515, 1948, 1426, 1518, 1841, 1400};
- String temp1;
- int temp2;
- //classify the flights by departure
- for(int i=0; i<departureTime.length; i++)
- {
- for(int j=1; j<(departureTime.length-i); j++)
- {
- if(departureTime[j-1]<departureTime[j])
- {
- temp1 = flightNumber[j-1];
- flightNumber [j-1] = flightNumber[j];
- flightNumber[j] = temp1;
- temp2 = departureTime[j-1];
- departureTime[j-1] = departureTime[j];
- departureTime[j] = temp2;
- }
- }
- }
- for(int i=0; i<departureTime.length; i++)
- System.out.println("Your flight is " + flightNumber[i] + " departing at " + departureTime[i]); //the number of flights and their departures
- //in ascending order
- }//class ends
- }//program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement