micher43

P7.5

Nov 15th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class TheaterChart {
  5.  
  6.     public static void main(String[] args) {
  7.        
  8.         int[][] theaterChart = {
  9.                   { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  10.                   { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  11.                   { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  12.                   { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  13.                   { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  14.                   { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  15.                   { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
  16.                   { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
  17.                   { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 },
  18.         };
  19.        
  20.         int rows = 10;
  21.         int columns = 9;
  22.        
  23.         Scanner scan = new Scanner(System.in);
  24.        
  25.         System.out.println("Do you want to choose a seat (input s), choose a price (input p) or quit (input q)");
  26.         String input = scan.nextLine();
  27.        
  28.        
  29.        
  30.         //when user pushes s
  31.         if(input.charAt(0) == 's'){
  32.            
  33.         System.out.println("enter a seat to choose. please enter two digits separated without a space.");
  34.         System.out.println("the first digit should be btwn 0-8 and the second should be btwn 0-9");
  35.         System.out.println("enter the first digit now");
  36.         int firstNumber = scan.nextInt();
  37.         System.out.println("entire the second digit now");
  38.         int secondNumber = scan.nextInt();
  39.        
  40.         if(theaterChart[firstNumber][secondNumber] != 0){
  41.             System.out.println("this seat is available");
  42.             System.out.println("do you want to choose this seat? input y for yes or n for no");
  43.             char choice = scan.next().charAt(0);
  44.            
  45.             if(choice == 'y'){
  46.                 theaterChart[firstNumber][secondNumber] = 0;
  47.             }
  48.            
  49.         }
  50.        
  51.        
  52.        
  53.        
  54.         }
  55.        
  56.                
  57.         //when user pushes p
  58.         if(input.charAt(0) == 'p'){
  59.             System.out.println("enter either 10, 20, 30, 40, or 50 as your price");
  60.             int priceInput = scan.nextInt();
  61.            
  62.             for(int i = 0; i < columns; i++){
  63.                
  64.                 for(int j = 0 ; j < rows; j++){
  65.                    
  66.                     if(theaterChart[i][j] == priceInput){
  67.                         System.out.println(i + " " + j);
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.        
  73.     }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment