Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BookingSystem {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[] seatNo = new int[30];
- int seats=0, seatsCounter;
- int yesOrNo = 1;
- String customerName;
- do {
- System.out.print("Welcome to ALX cinema! \n Please enter your name: ");
- customerName = sc.nextLine();
- System.out.println("Welcome, " + customerName);
- System.out.println("Please have a look at the seating plan:");
- for (int i = 0; i <= 30; i++) {
- System.out.print("-");
- }
- System.out.println();
- System.out.print("SEATING PLAN");
- System.out.println();
- for (seatsCounter = 0; seatsCounter < seatNo.length; seatsCounter++) {
- if (seatsCounter % 5 == 0) {
- System.out.println();
- }
- System.out.printf("%d \t",(seatsCounter + 1));
- }
- System.out.println();
- for (int j = 0; j <= 30; j++) {
- System.out.print("-");
- }
- System.out.println();
- System.out.print("Which seat would you like to book? ");
- int chosenSeats = Integer.parseInt(sc.nextLine());
- while (chosenSeats < 1 || chosenSeats > 30) {
- System.err.print("You have to choose from 1 to 30\nPlease Select again: ");
- chosenSeats = sc.nextInt();
- }
- // DO THE REST OF THE CODE HERE!
- System.out.print("Would you like to make another booking? Press 1 for Yes, 2 for No: ");
- yesOrNo = Integer.parseInt(sc.nextLine());
- } while (yesOrNo == 1);
- System.out.println("Thanks for booking!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment