Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheaterChart {
- 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 = 10;
- int columns = 9;
- Scanner scan = new Scanner(System.in);
- System.out.println("Do you want to choose a seat (input s), choose a price (input p) or quit (input q)");
- String input = scan.nextLine();
- //when user pushes s
- if(input.charAt(0) == 's'){
- System.out.println("enter a seat to choose. please enter two digits separated without a space.");
- System.out.println("the first digit should be btwn 0-8 and the second should be btwn 0-9");
- System.out.println("enter the first digit now");
- int firstNumber = scan.nextInt();
- System.out.println("entire the second digit now");
- int secondNumber = scan.nextInt();
- if(theaterChart[firstNumber][secondNumber] != 0){
- System.out.println("this seat is available");
- System.out.println("do you want to choose this seat? input y for yes or n for no");
- char choice = scan.next().charAt(0);
- if(choice == 'y'){
- theaterChart[firstNumber][secondNumber] = 0;
- }
- }
- }
- //when user pushes p
- if(input.charAt(0) == 'p'){
- System.out.println("enter either 10, 20, 30, 40, or 50 as your price");
- 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(i + " " + j);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment