Advertisement
angeloeboy10

JavaCode

Jan 11th, 2021 (edited)
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class SeatReservationn {
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.  
  8.         String busSeats[][] = new String[10][4];
  9.         String numchoice;
  10.         int choices[] = {0,0};
  11.  
  12.         for(int row = 0; row < busSeats.length; row++){
  13.             for(int column = 0; column < busSeats[0].length; column++){
  14.                 busSeats[row][column] = "*";
  15.             }
  16.         }
  17.  
  18.         do{
  19.             System.out.println("Bus Seat Reservation: ");
  20.  
  21.             System.out.println("\t\tCol 1 \t Col 2 \t Col 3 \t Col 4");
  22.  
  23.             for(int row = 0; row < busSeats.length; row++){
  24.  
  25.                 if((row+1) != 10){
  26.                     System.out.print("Row " + (row + 1) + "  |");
  27.                 }else{
  28.                     System.out.print("Row " + (row + 1) + " |");
  29.                 }
  30.  
  31.                 for(int column = 0; column < busSeats[0].length; column++){
  32.                     System.out.print("  "+ busSeats[row][column] + "\t\t");
  33.                 }
  34.  
  35.                 System.out.println("");
  36.  
  37.             }
  38.  
  39.             System.out.print("Enter row and column number to reserve separated by space (Enter a negative number to exit): ");
  40.  
  41.  
  42.             numchoice = in.nextLine();
  43.             String[] StrNumChoice = numchoice.split(" ");
  44.  
  45.  
  46.             for(int i = 0; i < StrNumChoice.length; i++){
  47.                 choices[i] = Integer.parseInt(StrNumChoice[i]);
  48.             }
  49.  
  50.             if(choices[0] < 0){
  51.                 System.out.println("Program Exit!");
  52.             }else{
  53.                 busSeats[choices[0] - 1][choices[1] - 1] = "X";
  54.             }
  55.  
  56.  
  57.         } while(choices[0] > 0);
  58.  
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement