C++, ARRAYS... I guess I haven't grasped that concept

Joined
Dec 1, 2007
Messages
1
Reaction score
0
What's up guys, I'm pretty much new here but have lurked around for a lil while. I'm a freshman computer engineer and I'm currently in an intro to programming C++ course. So far, I like it. I'm usually able to teach myself everything I need to know quickly (like a day before a program is due LOL), I'd probably be much better at this if I did study on the regular. I do plan on doing that next semester though (I mean, this is my major). Anyways, on to the problem.

This always happens when I learn something new in C++. I read it, I feel I have the concept grasped, but for some reason, it doesn't work for me in the end.

"Write a C++ application to assign seats on eac flight of the airline's only plan.

The seats on the plane will be numbered 0 - 9 to correspond to the indexes of the array. You should display a list of all available seats, then ask the user which seat he wishes to reserve a seat on the plane. The application should assign the requested seat and display a message indicating the user's seat number. Continue assigned seats until all seats are filled.

Application should never assign a seat that has already been assigned. When the plane is full, display a message stating that there are no seats available. The program should then stop execution."


Hints I were given were:

Create an array to represent the 10 seats on the plane
I assume this means I need to use something like "char seats[10] = {'1', '2', etc..}


Initialize all elements to 0 to indicate that no seats are taken.
So does this contradict the first statement? This tells me I should do "int seats[10] = {0}"

When a seat is filled, store another character other than 0 in that element
I don't have an idea for this. I guess, when a user inputs "3" then it adds 3 to the third seat, changing the value so that it is greater than 0? But I can't think of a statement that will only display seats that are 0.... while (x = 0) ??? Nah that wouldn't work... Ugh now I'm getting confused..

Continue looping process til all seats are assigned
This kinda ties into the last statement





I could post the piece of code I have but it really is wrong and isn't nearly done. I need help with this one. I'd write more on my status but I have to go for now, I'll be back in a couple of hours to clean up this post.

I appreciate your time if you've read this far :D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top