As a sidenote, for bonus points: the big part of your code are if statements that convert start and stop stations s and d into f fare , starttime and stoptime. What happens to the length of your code if you have 10 stations? It explodes because you would need 81 if statements! There is an easier way to do this. Hint: compare for each case d - s with the fee. Do you see a pattern? Now compare the d to the starttime.
Same for s. See if you can simplify your code so that it seems doable to 'in the future' expand to 10 stations without writing a lot of code. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Seat reservations and check if seats are available Ask Question. Asked 6 years, 1 month ago. Active 6 years, 1 month ago. Viewed 8k times. This is a school project. I have finished most of it, but I am stuck on something. Here's what I have done till now: import java. Book Ticket" ; System. Exit" ; System. I have an airplane seating program but I don't know how to get it to print the number of seats still available and how to get it to quit when I enter q.
Any help would be greatly appreciated. Yours truly, Quang Pham. The printout of the seat arrangement is good and the X goes where it should.
You have declared so many unnecessary variables e. Also, make filled as a global static variable so that it can be accessed in main and all other methods. Alternatively, you can pass it as an argument to the methods. I'm still working on the sentinel q for quit part.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Airplane seating program 2 dimensional array Ask Question. Asked 1 year, 9 months ago. Active 14 days ago. Assume a small airplane with seat numberings as follows:. The program should display the seat pattern, with an 'X' marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like the following:.
After displaying the seats available, the program should prompt for the seat desired, the user can type in a seat, and then the display of available seats should be updated. This program can be done using either a single-dimensional array or a multi-dimensional array. Since, we only discussed single-dimensional arrays in class, do this program using a single-dimensional array. As with all your programs, be sure to include the standard header talked about in class in your program.
Also, be sure to comment your program appropriately. Welcome to the site. For us to best help you with your assignment, please post all relevant code and any specific questions that you have. It looks pretty good sofar. It becomes a little unclear when you have the user attempt to retype only a column when the seat is occupied. We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.
You're trying to visit a URL that doesn't currently exist on the web.
0コメント