Re: Visual C++.NET - Help!

From: Stephen Tyndall (swtyndall_at_hotmail.com)
Date: 07/01/04


Date: Wed, 30 Jun 2004 23:06:02 -0500

Maybe you could use a pair of bool arrays instead of one int array? You
could have loops evaluate seat numbers and assign the seats to the
passengers in their chosen section. If all the seats in a class (Economy or
First Class) evaluated true (1 - meaning occupied), you could ask the user
if they wanted a seat in another section. Just a suggestion. You'll have
to forgive me if this is stupid somehow; I haven't been at this for long.

"Simon" <me2@aol.com> wrote in message
news:ujNDc.16913$bs4.5611@newsread3.news.atl.earthlink.net...
>
>
> Simon wrote:
> > I am a programming student and have recently missed two weeks of school
due
> > to a serious injury in a car accident. I am completing all of my
> > assignments (via Labs) but have come across the following lab and can't
seem
> > to put it all together. The scenario:
> >
> >
> > 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 "First Class" 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 whether it is in the first class
or
> > economy section of the plane.
> >
> >
> >
> > Use a single-subscripted array to represent the seating chart of the
plane.
> > Initialize all the elements of the array to 0 in indicate that the 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."
> >
> >
> >
> > Any suggestions? I have a few ideas but I would rather hear some other
> > ideas...
> >
> > Thanks in advance,
> >
> > Simon
> >
> >
> >
>
> Thank you for the advice so far. Looking at this original post I
> realize that it appeared like I just wanted someone to do the work for
> me. That's not the case at all. The fact is that I am a beginner
> programming student and I am finding that I have no problem learning the
> languages themselves, but have a bit of trouble coming up with the
> algorithms necessary to create solutions to problem. Is this something
> that comes with experience?
>
> The accident thing is true - I reinjured an already aggrivated condition
> in my spine (disk herniations, ffacet joint damage, and nerve damage in
> general). Lately I am on more narcotics than usual and seem to be
> having a harder time concentrating than usual.
>
> Anyway, this is what I have so far:
>
> Promt user for coach or first class:
>
> String *choice;
>
> //Prompt for First Class or Coach:
> Console::WriteLine(S"Please enter <1> for First Class ");
> Console::WriteLine(S"\nPlease enter <2> for Coach ");
>
> // Obtain number from user:
> choice = Console::ReadLine();
>
>
> The array for the seating chart:
>
> // Declare Array:
> Console::WriteLine(S"Seating Chart");
> int seatingArray[10];
> int i;
>
> for (i=0; i<10; i++) {
> seatingArray[i] = i;
> Console::WriteLine(seatingArray[i]);
> }
>
>
> return 0;
>
>
> I am planning on using if statements for the seat availability
> confirmations.
>
> My problem s are:
>
> - finding a way to assign the seats (maybe using random?)
>
> - initializing the array to zero
>
> These parts:
> "... Your program should print a boarding pass indicating the person’s
> seat number and whether it is in the first class or economy section of
> the plane."
>
> "...Use a single-subscripted array to represent the seating chart of the
> plane..."
>
> Single subscripted array?
>
> "...Initialize all the elements of the array to 0 in indicate that the
> 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...."
>
> Any suggestions?
>
> This is the full code (just a start):
>
> int _tmain()
> {
> String *choice;
>
> //Prompt for First Class or Coach:
> Console::WriteLine(S"Please enter <1> for First Class ");
> Console::WriteLine(S"\nPlease enter <2> for Coach ");
>
> // Obtain number from user:
> choice = Console::ReadLine();
>
> // Declare Array:
> Console::WriteLine(S"Seating Chart");
> int seatingArray[10];
> int i;
>
> for (i=0; i<10; i++) {
> seatingArray[i] = i;
> Console::WriteLine(seatingArray[i]);
> }
>
>
> return 0;
> }
>
> Thanks,
>
> Simon
>



Relevant Pages

  • Re: Visual C++.NET - Help!
    ... asked for a single array; in that case you could use just one bool array and ... As each seat is assigned, set the corresponding elements of the ... When the first class section is full, ... then make the appropriate seat assignment. ...
    (comp.lang.cpp)
  • Re: Visual C++.NET - Help!
    ... Don't worry about the Boarding Pass yet, get the seat allocation ... The stub will look like: ... An ssa is a sort of array. ... array with a "single subscript", that is an array with one subscript. ...
    (comp.lang.cpp)
  • Re: Visual C++.NET - Help!
    ... Simon wrote: ... > assignments but have come across the following lab and can't seem ... > If the person types 2, your program should assign a seat in the economy ... > Use a single-subscripted array to represent the seating chart of the plane. ...
    (comp.lang.cpp)
  • Re: Visual C++.NET - Help!
    ... > Simon wrote: ... >> assignments but have come across the following lab and ... >> If the person types 2, your program should assign a seat in the economy ... >> array to 1 to indicate that the seat is no longer available. ...
    (comp.lang.cpp)
  • Re: BA places corpse next to first-class passenger
    ... What if she had a middle seat? ... economy where the dead person used to sit. ... grieving relatives, was moved into first class, and placed in an empty ... deceased relatives between east and west. ...
    (rec.travel.air)