I am a student new to C++ and I am being asked to write a lab displaying airline flight schedules. The problem is I dont know how to start and I am having trouble being confident enough to assign constant variables and create structures as this is my first programming class.
(Any help would be greatly appreciated.)
Here is the prompt:
Develop a program that will be used to monitor the flight information at an airport.
The information to be maintained includes:
? the carrier (Southwest, United Airlines, Delta...),
? flight number,
? whether it is an arriving or departing flight,
? published arrival or departure time – this is the time promoted when booking flights
(use a 24-hour format; i.e., 2115 is 15 minutes after the 21st hour, or 9:15 p.m.),
? actual arrival/departure time - the time updated as the flight gets closer
? arrival or departure location (city).
Your program should allow the user to:
1. Add flight information,
2. Delete flight information
3. Display all flights
4. Display all arrival OR all departing flight information
5. Update the actual time of a flight
Program Design Notes:
? Create named constants to be used globally (ie. array sizes)
? Create a structure to hold flight information for one flight
o Carrier name will not exceed 20 characters
o Flight number will be an integer value not to exceed three digits,
o Arrival will be a char (‘A’- meaning arrival, ‘D’- meaning departure),
o Arrival or Destination City will not exceed 20 characters
o Published time and Actual time will be integers
? Divide the tasks into functions. See the structure chart on page 3.
You may use this design or one of your own.
Lines 29-30: Don't nest function prototypes inside main. Move these to line 11.
Line 31-43: You can't nest a function definition inside main.
Line 31: What is a GameType? Don't you mean Flightinfo?
Line 36: Not best style to mix C and C++ I/O. You should be using cout rather than printf.
Lines 22-23: Not clear what A and D are.
Line 18: Not clear what flight_Data is used for.
Lines 19,22,23: Why are you using C strings?
Line 20: Why is flightnum an array?
Line 35: This loop assumes you always have 100 flights.
Last edited on
AbstractionAnon has made some good points. Pay attention to them.
Starting at the top.
Delete line 3. You do not need to use C strings.
Line 6. Best to learn not to use this.
Line 8. I do not see any real use for this right now.
Line 9. Could be useful.
Line 10. Since you defined "flightnum" as an array which element do you want to set to 3?
Line 11. Is where lines 16 - 30 should go.
For the struct:
After thinking about it you should use std::string in place of the C style character arrays. You can check the length after the string has something in it and then limit it to 20 characters if needed. We can cover that later.
Line 20. Is a three element array. The  does not limit the number to three digits. You will need to check the size of the number, i.e., verify that it is three digits, when the number is entered.
Lines 22 and 23. This should be a single "char" to hold the letters "A" or "D" nothing more. Neither should be an array.
Lines 24 and 25. This will work, but if you decide to add a colon later it becomes much more involved. That is why I broke this down to hours and minutes in separate variables.
Line 26. Giving a name to "Flightinfo" is fine if you use it correctly. This just means that you do not have to define "flightData" in main.
Lines 31 to 43. Should be put after main not in main.
What is after main right now I will have to work on later.
For the "display" function:
As AbstractionAnon said
Line 36: Not best style to mix C and C++ I/O. You should be using cout rather than printf. That said the "printf" will not work the way you have it. You are trying to print 4 variables, but you are listing 7 variables to print. And the format specifiers you are using do not match the variables that you are using. The "std::cout" would be a better choice.
The whole "Display" function look like you copied it, but forgot to change it to what you actually need.
After you get what you have straightened up I would work on the "getData" function and change to match your program and get it working.
Hope that helps,