Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 6.24 from textbook (BIG JAVA LATE OBJECTS): A theater seating chart is i

ID: 3758106 • Letter: P

Question

Problem 6.24 from textbook (BIG JAVA LATE OBJECTS): A theater seating chart is implemented as a two- dimensional array of ticket prices, like this:

3 6 7 9

10 11 12 13

14 15 16 17

19 21 23 25

The price of the seat number 1 is $3. The price of the seat number 2 is $6. ... The price of the seat number 5 is $10 ... The price of the seat number 16 is $25

Write a program that prompts users to pick either a seat or a price.

Mark sold seats by changing the price to 0. When a user specifies a seat, make sure it is available.

You will display a message "Sorry, the seat is not available."

When a user specifies a price, find any seat with that price.

The seat number is identifed using the row and column.

For example, if row is 0 and column is 0, the seat is $3.

Again, if row is 1 and column is 2, then the seat is $12.

-------------------------------------------------------------------

This is my code so far. When I enter a price, I am unable to find out if the price is found or not. Can you help me finish the code and comment on each line what your code is doing/ if I'm doing something wrong??? THank you

-------------------------------------------------------------------

  

import java.io.*;
import java.util.*;
public class Ticket
{
   public static void main(String[] args)
   {
Scanner in = new Scanner(System.in);
int[][] SeatPrice =
{
   {3,6,7,9},
   {10,11,12,13},
   {14,15,16,17},
   {19,21,23,25}
};

System.out.println("Enter "1" if you're looking for a price, or "2" for a seat. ");
int decision = in.nextInt();

if(decision == 1)
{
   FindPrice(SeatPrice);
}
else
{
   FindTicket(SeatPrice);
}
   }
  
   public static int FindPrice(int[][] p_SeatPrice)
   {
   boolean found = false;
Scanner in = new Scanner(System.in);
System.out.print("What price do you want? (Whole dollar amount only) $");
int price = in.nextInt();

if(price > 25)
{
   System.out.print("Sorry price is not available");
}

else
{
   for(int i = 0; i < 3; i++)
   {
for(int j = 0; j < 3; j++)
{
   if(p_SeatPrice[i][j] == price)
   System.out.print("Your ticket has been reserverd!!");
   found = true;
}

  
   }
  
  
  
  
   /*
   int i = 0;
   boolean found = false;
   while (i < p_SeatPrice.length && !found)
   {
if (p_SeatPrice[i] == price)
{
   found = true;
}
else
   {
   i++;
}
   }
  
   if (found)
   {
System.out.println("Found at position: " + i);
   }
   else
   {
System.out.println("Not found");
   }
   */
  
  
}


return price;
   }
  
   public static int FindTicket(int[][] p2_SeatPrice)
   {
Scanner in = new Scanner(System.in);
System.out.print("Please enter a seat number by choosing a row, then column (example: 9 9)");
int seat = in.nextInt();

return seat;
   }
  

}

Explanation / Answer

CODE :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote