Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Josh Jurban
- package chapter6;
- import java.util.Scanner;
- public class TheaterSeating
- {
- public static void main(String[] args)
- {
- int[][] theaterChart =
- {
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
- { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
- { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
- { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 },
- };
- int rows = 9;
- int columns = 10;
- Scanner scan = new Scanner(System.in);
- System.out.println("[1] Choose by seat");
- System.out.println("[2] Choose by price");
- String input = scan.nextLine();
- if(input.charAt(0) == '1')
- {
- System.out.println("Seating Chart:");
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < columns; j++)
- {
- System.out.printf("%8d", theaterChart[i][j]);
- System.out.printf("$");
- }
- System.out.println();
- }
- System.out.println();
- System.out.println();
- System.out.println("(rows 0-8 |)");
- System.out.println("( V)");
- System.out.println();
- System.out.println("(columns 0-9 -->)");
- System.out.println(" ");
- System.out.println();
- System.out.println();
- System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
- System.out.println("Enter row number");
- int theaterRowNumber = scan.nextInt();
- System.out.println("Enter column number");
- int theaterColumnNumber = scan.nextInt();
- if (theaterChart[theaterRowNumber][theaterColumnNumber] == 0)
- {
- System.out.println("Sorry, this seat isn't avalailable");
- }
- else
- {
- System.out.print("Your seat is booked for row " + theaterRowNumber );
- System.out.print(", column " + theaterColumnNumber);
- System.out.println();
- System.out.println("That will be " + theaterChart[theaterRowNumber][theaterColumnNumber] + "$" );
- theaterChart[theaterRowNumber][theaterColumnNumber] = 0;
- }
- }
- if(input.charAt(0) == '2')
- {
- System.out.println("Choose a price! Pricing for seats are 10$, 20$, 30$, 40$, 50$");
- int priceInput = scan.nextInt();
- for(int i = 0; i < columns; i++)
- {
- for(int j = 0 ; j < rows; j++)
- {
- if(theaterChart[i][j] == priceInput)
- {
- System.out.println("Available seats are at row " + i + ", column " + j);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement