카테고리 없음

Seating Chart Program Java

tioadsaloconcel 2021. 1. 27. 04:20


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-dimmension array of ticket prices like this. I have a java programming assignment that requires multiple programs to be written One is a.

Active5 years, 5 months ago

Let me first say, this is a 'Lab' that I'm doing for class, and I've been working on this second of two programs for around 5 hours now, probably 2 of them stuck on this one part. Let me first give you the requirements of the program so that maybe all of this will make a bit more sense.

A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:

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.

That's the book's description, here's what my professor has given me to go with as well.

Seating Chart Program Java

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. Serial key. Your program should have at least 3 static methods that i) print the array, ii) sellSeatByPrice, and iii)sellSeatByNumber. Please declare and initialize your array to the provided seat price values in main.

What I've gotten myself stuck on for around 2 hours is figuring out how to change just one of the numbers of the 2D array to a 0. Say I entered a seat for 30, I've changed my code around 5 times now to get it to work and I'll either have every 30 change to a 0, or a few of them, or none. The main portion I need help on is the method called sellSeatByPrice(). Currently I'm not getting any numbers to change. Here's my current full code:

(I do apologize if this looks sloppy, it's 3am and I can't think anymore)

MikeNMikeN

2 Answers

Sourabh BhatSourabh Bhat

First, you check found true (which can be shortened to if (found), by the way). found is initialized to false and is never touched again, so the check fails every time.

You don't even need a boolean variable here. Iterate over the seats; if a seat has the price you're looking for, set the seat's price to 0, print the array and return (break only exits the inner for loop).

Fallout 2 high resolution patch unsupported version. The purpose of this project is to add back into Fallout 2 all the missing content (locations, NPCs, quests, items, etc) that were pulled or left unfinished in the original game. In addition to (or instead) the unofficial patch, you can install the F2 Restoration Project. Hello guys i have hudge problem i installed the RP, and in the game i have some misssing text 'error'. • Download and easily install the expansion here: [killap.net]. This expansion attempts to stay true to what made Fallout great and thus the new content you find is not something I felt that would be cool to see, but rather a reality of what the original devs wanted.

Gabriel NegutGabriel Negut
11.8k3 gold badges31 silver badges42 bronze badges

Not the answer you're looking for? Browse other questions tagged javaarrays2d or ask your own question.

Active5 years, 6 months ago

I'm doing a Simple seat reservation which uses to dimensional arrays. The program should asked the user to input a seat number and replaced the reserved with 0 also user is not allowed to reserve a previously reserved seat and should displayed 'seat taken'. I have the two dimensional array table (credits to other stackoverflow members which help me through this) and now i don't have the idea how to change the seat number to 0. Could you guys give me some ideas how to work this out. thanks!

here is my code:

Shashi
6,66812 gold badges54 silver badges104 bronze badges
kixkix
Java

3 Answers

I think this is what you want:

This code searches for the seat number that has just been entered from the console and sets it to 0;

DevinDevin

Free Classroom Seating Chart Program

First of all, I would use 1 or any other value to define if a seat is taken, since int values are by default initialized to 0. If you insist in using 0 you'll have to initialize your whole two dimentional array to a value different than 0.

Also, if your seats are defined by a number from 1 to 35 and you only define if a seat is taken or not, I suggest you use an array (not a table) of booleans. They take the values true and false and are easier to use in this kind of situations.

with that in mind, just do:

And the value will be assigned to the element represented by the index. Then, to consult if a seat is already taken:

If you trylly want to use ints, I'll still encourage you to use 1 as the 'taken' value.

CoolROM.com's game information and ROM (ISO) download page for Winning Eleven - Pro Evolution Soccer 2007 (Sony Playstation 2). CoolROM.com's game information and ROM (ISO) download page for Winning Eleven - Pro Evolution Soccer 2007 (Sony Playstation 2). Winning Eleven Pro Evolution Soccer 2007 PSP ISO Download free for PPSSPP Emulator on PC and Android Compressed RAR Archive Direct Link available now with full speed features. Winning Eleven Pro Evolution Soccer 2007 PSP ISO Download free for PPSSPP Emulator on PC and Android Compressed RAR Archive Direct Link available now with full speed. Pro Evolution Soccer 6 is a soccer game made by Konami. Now you can add videos, screenshots, or other images (cover scans, disc scans, etc.) for Winning Eleven - Pro Evolution Soccer 2007 (USA) (En,Fr,De,Es,It) to Emuparadise. Pro Evolution Soccer 6 is a soccer game made by Konami. Now you can add videos, screenshots, or other images (cover scans, disc scans, etc.) for Winning Eleven - Pro Evolution Soccer 2007. Pro evolution soccer 2007 demo.

So you set a reserved value like this

To check if a seat is taken, the process is slightly different. You'll need to use . In this case (primitives) It'll check if both values are the same. (Later, when you use objects you'll want to use equals() instead).

In all of the cases, seat is the int that represents the user's input.

FritzJava

Seating Chart Program For Teachers

Fritz
9,1584 gold badges24 silver badges47 bronze badges

Free Seating Chart Program

SMR

Classroom Seating Chart Program

5,7902 gold badges28 silver badges54 bronze badges
Edwin S. GarciaEdwin S. Garcia

Bar Chart Java Program

Not the answer you're looking for? Browse other questions tagged javamultidimensional-array or ask your own question.