Advertisement
JoshJurban

Project 7.5

Nov 25th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.82 KB | None | 0 0
  1. //Josh Jurban
  2.  
  3. package chapter6;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class TheaterSeating
  8. {
  9.         public static void main(String[] args)
  10.         {
  11.                 int[][] theaterChart =
  12.                 {
  13.                         { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  14.                         { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  15.                         { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  16.                         { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  17.                         { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  18.                         { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  19.                         { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
  20.                         { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
  21.                         { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 },
  22.                 };
  23.                          
  24.                 int rows = 9;
  25.         int columns = 10;
  26.        
  27.         Scanner scan = new Scanner(System.in);
  28.        
  29.         System.out.println("[1] Choose by seat");
  30.         System.out.println("[2] Choose by price");
  31.         String input = scan.nextLine();
  32.        
  33.        
  34.             if(input.charAt(0) == '1')
  35.             {
  36.                     System.out.println("Seating Chart:");
  37.                     for (int i = 0; i < rows; i++)
  38.                     {
  39.                        
  40.                         for (int j = 0; j < columns; j++)
  41.                         {
  42.                        
  43.                           System.out.printf("%8d", theaterChart[i][j]);
  44.                           System.out.printf("$");
  45.                         }
  46.                         System.out.println();
  47.                         }
  48.                         System.out.println();
  49.                         System.out.println();
  50.                         System.out.println("(rows 0-8 |)");
  51.                         System.out.println("(         V)");
  52.                         System.out.println();
  53.                         System.out.println("(columns 0-9 -->)");
  54.                         System.out.println("            ");
  55.                         System.out.println();
  56.                         System.out.println();
  57.                         System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  58.                    
  59.                         System.out.println("Enter row number");
  60.                         int theaterRowNumber = scan.nextInt();
  61.                         System.out.println("Enter column number");
  62.                         int theaterColumnNumber = scan.nextInt();
  63.                      
  64.                         if (theaterChart[theaterRowNumber][theaterColumnNumber] == 0)
  65.                         {
  66.                           System.out.println("Sorry, this seat isn't avalailable");
  67.                         }
  68.                         else
  69.                         {
  70.                             System.out.print("Your seat is booked for row " + theaterRowNumber );
  71.                             System.out.print(", column " + theaterColumnNumber);   
  72.                             System.out.println();
  73.                             System.out.println("That will be " + theaterChart[theaterRowNumber][theaterColumnNumber] + "$" );
  74.                             theaterChart[theaterRowNumber][theaterColumnNumber] = 0;
  75.                         }
  76.                        
  77.                 }
  78.            
  79.                 if(input.charAt(0) == '2')
  80.                 {
  81.                     System.out.println("Choose a price! Pricing for seats are 10$, 20$, 30$, 40$, 50$");
  82.                     int priceInput = scan.nextInt();
  83.                    
  84.                     for(int i = 0; i < columns; i++)
  85.                     {
  86.                            
  87.                             for(int j = 0 ; j < rows; j++)
  88.                             {
  89.                                    
  90.                                     if(theaterChart[i][j] == priceInput)
  91.                                     {
  92.                                             System.out.println("Available seats are at row " + i + ", column  " + j);
  93.                                     }
  94.                             }
  95.                     }
  96.                 }
  97.     }
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement