Need to use a class with an array of 10 structures in the private portion of the class and instances of this array of structures are to be created in the public portion (this will be the .h file).
Top level menu should have:
(E) to enter into
(D) to Display info (either of one passenger, two, or three, or all ten)
(Q) to quit
Passenger info will be inputted and when entered, top level menu will display
Display should include:
first name
last name
flight number
and membership (or priority)
Working on visual studio 2015. This is the code I have come up with so far and it runs but only for 1 flight entry. I am still unsure how to display 1, 2, 3, or all 10 flight entries simultaneously if more than one are inputted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#pragma once
#include <iostream>
using namespace std;
const char SIZE = 10;
class Flight
{
char prompt;
char loop = 'y';
char FName[SIZE];
char LName[SIZE];
double FltNum;
int Priority;
public:
void getFlight();
};
#include "TAir.h" //name of my .h file
void Flight::getFlight()
{
do
{
cout << "Press E to (E)nter flight information " << endl;
cout << "or press Q to (Q)uit program ";
cin >> prompt;
cout << endl;
switch (prompt)
{
case 'E':
case 'e':
cout << "Enter your frist name " << endl;
cin >> FName;
cout << "Enter your last name " << endl;
cin >> LName;
cout << "Enter your Flight Number" << endl;
cin >> FltNum;
cout << "Enter membership: 1 - Platinium 2 - Gold, 3 - Silver, 4 - Lead" << endl;
cin >> Priority;
cout << endl;
cout << " Flight Information: " << endl;
cout << "FirstName: " << FName << endl;
cout << "LastName: " << LName << endl;
cout << "FlightNumber: " << FltNum << endl;
if (Priority == 1)
cout << "Priority is Platinium " << endl;
else if (Priority == 2)
cout << "Priority is Gold " << endl;
else if (Priority == 3)
cout << "Priority is Silver " << endl;
else
cout << "Priority is Lead " << endl;
break;
case 'Q':
case 'q':
loop = 'n';
break;
default:
cout << "This is an invalid choice; please try again: " << endl;
}system("pause");
} while ((loop == 'y') || (loop == 'Y'));
}
int main()
{
Flight obj1;
obj1.getFlight();
cout << endl;
return 0;
}
|
Class/struct example from lecture notes recommended for use as a guideline on this assignment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
using namespace std;
const short MAX = 10;
class Alpha
{
struct Baker
{
short Name;
};
Baker Array[MAX];
public:
void getAlpha();
};
void Alpha::getAlpha()
{
Array[1].Name = 3;
cout << Array[1].Name << endl;
}
int main()
{
Alpha obj;
obj.getAlpha();
system("pause");
return 0;
}
|