*
aemazing@gmail.com:[color=blue]
> hello, im new to the forum[/color]
Instead of using Google's web based interface, consider using a newsreader
(client for usenet): it's much better.
[color=blue]
> the teacher wants us to design a progrm that would keep track of
> airplanes awaitin landing at an airport. the program will maintain a
> queue of flights numbers.
>
> the program will be abel to do the following:
>
> Add a new flight number to the end of the queue (got it done)
> LAnd the plane at the front of the queue - problems wit it-
> display the queue - got it done
> seach for a specific flight number in queue ( didn't get there yet)
> move a flight number one one position in the queue to another ( didn't
> get there yet)
>
> this is what i have so far. it runs but something is wrong and i don't
> know what it is.[/color]
You should describe what you expect, and what you actually get.
[color=blue]
> #include <iostream>
> #include <iomanip>
> using namespace std ;
>
> const int MAXQUEUE = 100 ; // maximum number of flights in the queue[/color]
Don't use all uppercase except for macros, where you should always.
[color=blue]
> void displayQueue (int[], int) ;
> void getChoice ();
> void addPlane (int[], int&) ;
> int checkPlane (int[], int, int) ;[/color]
Don't use raw arrays. Use e.g. std::vector.
[color=blue]
> int main ()
> {
> int queue[MAXQUEUE] ; // array of incoming flight numbers
> int qsize = 0 ; // number of flights in the queue
> char choice; // user's choice of next operation
>
> do
> { // start menu loop
> displayQueue (queue, qsize) ;
> getChoice();
> switch (choice)
> { // start switch
> case 'S' : cout << "under construction" << endl; break ;
> case 'L' : cout << "under construction" << endl; break ;
> case 'A' : addPlane (queue, qsize) ; break ;
> case 'M' : cout << "under construction" << endl; break ;
> case 'Q' : cout << "program ended" << endl ;
> } // end switch
> } while (choice != 'Q'); // end menu loop
>
> return 1 ;
> }[/color]
Indentation. It may be that Google f*cks this up. Try a newsreader instead
of Google's web-based interface.
[color=blue]
> //============displayQueue=====================
> // task - display the position and flight number of each flight in the
> array
> // pre - given an array of flight numbers and number of flights in the
> array
> // post - nothing
>
> void displayQueue (int list[], int lsize)
> { // start function
> int w ;
> cout << endl << endl << endl ;
> if (lsize == 0)
> cout << "no flights awaiting landing at this time" << endl ;
> else
> { // start listing
> cout << "Queue size = " << lsize << endl << endl ;
> cout << "Position Flight#" << endl ;
> for (w = 0; w < lsize; w++)
> cout << setw(5) << w + 1 << setw(12) << list[w] << endl ;
> } // end listing
> } // end function[/color]
[color=blue]
> //============getChoice========================
> // task - obtain a choice code from the user
> // pre - nothing
> // post - a valid, uppercase code is returned[/color]
Oops, a void function doesn't return anything.
[color=blue]
> void getChoice()
> { // start function
> char holdCode;
> char pick;
>
>
> if(pick == holdCode)[/color]
Oops, uninitialized.
Now just correct those two errors, and possibly the indentation, and proceed
to the next error, and so on.
But you're strongly adviced to use std::vector, not a raw array.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?