Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SeatReservationn {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String busSeats[][] = new String[10][4];
- String numchoice;
- int choices[] = {0,0};
- for(int row = 0; row < busSeats.length; row++){
- for(int column = 0; column < busSeats[0].length; column++){
- busSeats[row][column] = "*";
- }
- }
- do{
- System.out.println("Bus Seat Reservation: ");
- System.out.println("\t\tCol 1 \t Col 2 \t Col 3 \t Col 4");
- for(int row = 0; row < busSeats.length; row++){
- if((row+1) != 10){
- System.out.print("Row " + (row + 1) + " |");
- }else{
- System.out.print("Row " + (row + 1) + " |");
- }
- for(int column = 0; column < busSeats[0].length; column++){
- System.out.print(" "+ busSeats[row][column] + "\t\t");
- }
- System.out.println("");
- }
- System.out.print("Enter row and column number to reserve separated by space (Enter a negative number to exit): ");
- numchoice = in.nextLine();
- String[] StrNumChoice = numchoice.split(" ");
- for(int i = 0; i < StrNumChoice.length; i++){
- choices[i] = Integer.parseInt(StrNumChoice[i]);
- }
- if(choices[0] < 0){
- System.out.println("Program Exit!");
- }else{
- busSeats[choices[0] - 1][choices[1] - 1] = "X";
- }
- } while(choices[0] > 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement