Advertisement
angeloeboy10

CODE MAY COMMENT

Jan 13th, 2021
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Test {
  7.     public static void main(String[] args) {
  8.         Scanner in = new Scanner(System.in);
  9.  
  10.         String [][] seats = {
  11.                 { " *"," *", " *", " *" },
  12.                 { " *"," *", " *", " *" },
  13.                 { " *"," *", " *", " *" },
  14.                 { " *"," *", " *", " *" },
  15.                 { " *"," *", " *", " *" },
  16.                 { " *"," *", " *", " *" },
  17.                 { " *"," *", " *", " *" },
  18.                 { " *"," *", " *", " *" },
  19.                 { " *"," *", " *", " *" },
  20.                 { " *"," *", " *", " *" }
  21.         };
  22.  
  23.         int choiceSeat[] = {0,0};
  24.  
  25.         // Ito yung do loop. Nilagay sa loob para mag loloop lang hanggang true yung while sa baba check mo.
  26.         do{
  27.             System.out.println("Bus Seat Reservation: ");
  28.             System.out.println("\t\tCol 1 \t Col 2 \t Col 3 \t Col 4");
  29.  
  30.             for(int row = 0; row < seats.length; row++){
  31.  
  32.                 if((row+1) != 10){
  33.                     System.out.print("Row " + (row + 1) + " |");
  34.                 }else{
  35.                     System.out.print("Row " + (row + 1) + "|");
  36.                 }
  37.                 for(int column = 0; column < seats[row].length; column++){
  38.                     System.out.print( " " + seats[row][column] + "\t\t" );
  39.                 }
  40.                 System.out.println();
  41.             }
  42.  
  43.             System.out.print("Enter row and column number to reserve separated by space (Enter a negative number to exit): ");
  44.  
  45.             String NumSchoice;
  46.             NumSchoice = in.nextLine();
  47.             String[] StrSchoice = NumSchoice.split(" ");
  48.  
  49.  
  50.             for(int i = 0; i < StrSchoice.length; i++){
  51.                 choiceSeat[i] = Integer.parseInt(StrSchoice[i]);
  52.             }
  53.  
  54.             if(choiceSeat[0] < 0){
  55.                 System.out.println("Program exit!");
  56.             }else{
  57.                 seats[choiceSeat[0] - 1][choiceSeat[1] - 1] = "X";
  58.  
  59.             }
  60.  
  61.         }while (choiceSeat[0] > 0);
  62.         //Eto yung while. Hanggat Mas malaki sa 0 yung value magrurun siya. Meaning pag negative nilagay mo na input titigil yung program
  63.  
  64.     }
  65.  
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement