binibiningtinamoran

BookingSystem.java

Dec 19th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BookingSystem {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner sc = new Scanner(System.in);
  8.  
  9.         int[] seatNo = new int[30];
  10.         int seats=0, seatsCounter;
  11.         int yesOrNo = 1;
  12.         String customerName;
  13.  
  14.         do {
  15.             System.out.print("Welcome to ALX cinema! \n Please enter your name: ");
  16.             customerName = sc.nextLine();
  17.  
  18.             System.out.println("Welcome, " + customerName);
  19.             System.out.println("Please have a look at the seating plan:");
  20.  
  21.             for (int i = 0; i <= 30; i++) {
  22.                 System.out.print("-");
  23.             }
  24.  
  25.             System.out.println();
  26.             System.out.print("SEATING PLAN");
  27.             System.out.println();
  28.  
  29.             for (seatsCounter = 0; seatsCounter < seatNo.length; seatsCounter++) {
  30.  
  31.                 if (seatsCounter % 5 == 0) {
  32.                     System.out.println();
  33.                 }
  34.                 System.out.printf("%d \t",(seatsCounter + 1));
  35.             }
  36.  
  37.             System.out.println();
  38.             for (int j = 0; j <= 30; j++) {
  39.                 System.out.print("-");
  40.             }
  41.             System.out.println();
  42.  
  43.             System.out.print("Which seat would you like to book? ");
  44.  
  45.             int chosenSeats = Integer.parseInt(sc.nextLine());
  46.  
  47.             while (chosenSeats < 1 || chosenSeats > 30) {
  48.                 System.err.print("You have to choose from 1 to 30\nPlease Select again: ");
  49.                 chosenSeats = sc.nextInt();
  50.             }
  51.  
  52.             // DO THE REST OF THE CODE HERE!
  53.  
  54.  
  55.             System.out.print("Would you like to make another booking? Press 1 for Yes, 2 for No: ");
  56.             yesOrNo = Integer.parseInt(sc.nextLine());
  57.  
  58.         } while (yesOrNo == 1);
  59.  
  60.         System.out.println("Thanks for booking!");
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment