Permalink
Required Program Components: The initial seating chart in this solution is generated as shown in the example. The solution also assumes that the user will enter a row and seat which start at 1 and where row 1 is the bottom front row.
- Required Program Components: The initial seating chart in this solution is generated as shown in the example. The solution also assumes that the user will enter a row and seat which start at 1 and where row 1 is the bottom front row.
- JAVA PROBLEM A theater seating chart is implemented as a two-dimmension array of ticket prices like this: int[][] seats - Answered by a verified Tutor. A theater-seating chart is implemented as a two-dimensional array of ticket prices. I have a java programming assignment that requires multiple programs to be written One is a coin toss.
- Need some help with Java program Airline.java. Greenhorn Posts: 2. Posted 8 years ago. I am new to Java, and I have been using a book to learn it myself. I have hit a few snags, but have gotten through most of them without too much of an issue. I just came upon a problem int he book that I am stumped on. Seat = Console.readInt.
- I need help in this Java program. Show transcribed image text A theater seating chart is implemented as a two-dimensional array of ticket prices, like this: Write a program that prompts users to pick a price. Mark sold seats by changing the price to 0. When a user specifies a price, make sure it is available.
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
/*A theater seating chart is implemented as a two-dimensional array of ticket prices, |
like this: |
10 10 10 10 10 10 20 20 30 10 |
10 10 10 10 10 20 30 40 10 10 |
10 20 20 20 30 30 50 10 10 10 |
20 20 20 30 40 50 10 10 10 20 |
20 20 40 50 50 10 10 10 20 20 |
20 40 50 50 10 10 10 20 20 20 |
30 40 50 10 10 10 20 20 20 30 |
30 50 10 10 10 10 10 10 20 30 |
40 10 10 10 10 10 10 20 20 30 |
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. When a user specifies a price, |
find any seat with that price.*/ |
importjava.util.Scanner; |
publicclassP6_24 { |
publicstaticvoidmain(String[] args) { |
int[][] prices =newint[][] { |
{ 10, 10, 10, 10, 10, 10, 20, 20, 30, 10 }, |
{ 10, 10, 10, 10, 10, 20, 30, 40, 10, 10 }, |
{ 10, 20, 20, 20, 30, 30, 50, 10, 10, 10 }, |
{ 20, 20, 20, 30, 40, 50, 10, 10, 10, 20 }, |
{ 20, 20, 40, 50, 50, 10, 10, 10, 20, 20 }, |
{ 20, 40, 50, 50, 10, 10, 10, 20, 20, 20 }, |
{ 30, 40, 50, 10, 10, 10, 20, 20, 20, 30 }, |
{ 30, 50, 10, 10, 10, 10, 10, 10, 20, 30 }, |
{ 40, 10, 10, 10, 10, 10, 10, 20, 20, 30 } |
}; |
Scanner input =newScanner(System.in); |
System.out.print('Please enter (seat or price): '); |
String choose = input.next(); |
while (!(choose.equals('seat') || choose.equals('price'))) { |
System.out.print('Please enter (seat or price): '); |
choose = input.next(); |
} |
boolean isSold =false; |
while (!isSold) { |
if (choose.equals('seat')) { |
System.out.print('Please choose row: '); |
int row = input.nextInt(); |
System.out.print('Please choose column: '); |
int column = input.nextInt(); |
if (prices[row][column] !=0) { |
isSold =true; |
prices[row][column] =0; |
System.out.println('This seat is empty! You got it!'); |
} else { |
System.out.println('This seat is not empty! Pick another one!'); |
} |
} elseif (choose.equals('price')) { |
System.out.print('Plese choose price: '); |
int price = input.nextInt(); |
for (int i =0; i < prices.length; i++) { |
for (int j =0; j < prices[i].length; j++) { |
if (prices[i][j] price) { |
isSold =true; |
prices[i][j] =0; |
System.out.printf('This seat [%d, %d] is empty! You got it!n', i, j); |
break; |
} |
} |
if (isSold) { |
break; |
} |
} |
if (!isSold) { |
System.out.println('Please pick another price!'); |
} |
} |
} |
System.out.println('Goodbye! Have a nice day!'); |
input.close(); |
} |
} |
Copy lines Copy permalink
Free Classroom Seating Chart Program
Active2 years, 10 months ago
This array represents theater seats and I have to mark sold seats by changing the price to 0. I also have to make sure seats are open when a user asks for a a certain spot, and when a user enters a price, find any seats that are open.
So I'm pretty sure I figured out the code for finding the best seat at any given price. I can't figure out how to do the remaining code.
Serial communication with labview tutorial loops. If you are using LabVIEW NXG, learn programming basics by launching LabVIEW NXG and using the interactive lessons on the Learning tab. Core LabVIEW Concepts • —Examine the most important building blocks for any LabVIEW application, including the front panel, block diagram, palettes, controls, and indicators.
I just need to find out how to print the total available seats and also how to print the total available seats when a certain price is entered.
Thanks.
tobenatobena
1 Answer
You'd just use nested
for
loops, like you did before, except now you'd have some kind of a availableSeats
counter you'll increment every time a seat meets a certain condition.Like so:
Unless I'm not understanding the problem correctly.
zoosterzooster
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.