Answer to Question #279857 in Java | JSP | JSF for pink

Question #279857

Write a java program that will automate the actual process of passenger reservation in an actual public terminal. Each vehicle is assigned its predefined number of seats. Each passenger must be reserved to its desired seat number and must be processed.


1
Expert's answer
2021-12-15T07:00:07-0500


package passengerreservation;


import java.util.Scanner;


public class Passengerreservation {


   
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter the seat number: ");
        int d = scan.nextInt();
        boolean [] vehicle = new  boolean[50];
        vehicle[d]= true;
        int i=0;
        while(i<50){
            if(d>50 || vehicle[d] ==true ){
                 System.out.printf("Seat number %d is reserved successfully\n ", d);
                 break;
            }
            else{
                               vehicle[d] = true;
               
            }
            
            i++;
        }
        
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog