Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

I'm hoping someone could help me get started on a cpp assignment I have :/ I'm not looking for anyone to straight up do it for me, or anything like that, but I'm really hoping someone could help me get started with it, as I'm pretty much totally lost :( any help would be sincerely appreciated, as, as sad as it is, I'm horrible with programming, but it's a class that I have to stay in! I will post the description of the assignment in a response to this.

OpenStudy (anonymous):

"A small airline has just purchased a computer for its new automated reservations system. You have been asked to program the new system. You are to write a program to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Your program should display the following menu of alternatives—Please type 1 for "FirstClass" and Please type 2 for "Economy". If the person types 1, your program should assign a seat in the first class section (seats 1-5). If the person types 2, your program should assign a seat in the economy section (seats 6-10). Your program should print a boarding pass indicating the person’s seat number and whetherit is in the first class or economy section of the plane. Use a one-dimensional array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available. Your program should, of course, never assign a seat that has already been assigned. When the first class section is full, your program should ask the person if it is acceptable to be placed in the economy section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message "Next flight leaves in 3 hours."

OpenStudy (rsmith6559):

If you're lost at this point, take the description of the assignment (I hope it's in electronic form) and break it into individual sentences. Many of them will end up being either functions, or blocks of code. Rearrange them to where they're a workable sequence of instructions to do the job. Translate into code.

OpenStudy (anonymous):

Do you sort of mean like a flow chart (ie: the option of what seating, and then branch the individual things off of those different options), if so, I got a similar suggestion from a friend, and it seemed like a pretty good idea.

OpenStudy (rsmith6559):

If you like to draw, go for it. At this point, the task is to "decompose" the problem. In English, break it down into manageable parts. Flow charts can do this for linear problems, but go to heck pretty quick on non-linear problems. What I was trying for suggesting re-editing the problem, was to help you see the different steps that the description has. Rearranging it into sections, moving things around according to what you need first, and so on. If the problem is well broken down, code can be pretty simple to write. That said, someday I really should take my own advice!

OpenStudy (anonymous):

Okay, I think I get what you're saying, that does make sense! If you don't mind my asking, what would you suggest I include/declare (I'm not sure how much it may vary depending on how I end up writing the code), for some reason I always get confused when deciding what I should put in :/

OpenStudy (rsmith6559):

You and me both. You'll certainly need iostream, but I think that will do it.

OpenStudy (anonymous):

I shouldn't need to declare anything you don't think? Sorry if that's a really dumb question, my last assignment had to deal with min/max/average type stuff, and I had to make a bunch of declarations for that one

OpenStudy (rsmith6559):

iostream would be an include, not a declaration. Worry about breaking down the problem, then worry about the coding.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!