Help C++

can someone please help me, I need to create this menu driven program using arrays and I need the following code to compile to do the following:

1)enter flight data into arrays
2)print report by airline alphabetically
3)print report by destination alphabetically



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
80
81
82
83
84
85
86
87
#include <iostream>
#include <string>
using namespace std;

void menu();
void menuchoice();
void passengercheck();

char choice;
string name, destination;
double count=1, flightnumber, passengercount, totalpassengers=0;


int main()
{
	menu();
	menuchoice();
system("PAUSE");
return 0;

}

void menu()
{
	cout << "ABC TRAVEL AGENCY" << endl;
	cout << "1) Enter Flight Data" << endl;
	cout << "2) Print Report by Airline" << endl;
	cout << "3) Print Report by Destination" << endl;
	cout << "4) End Program" << endl;
	cin >> choice;
}

void menuchoice()
{
	if (choice == '1')//ENTER FLIGHT INFO
	{
	cout << "Charter number: " << count << endl;
	count++;

	//NEEDS TO BE INPUTTED IN ARRAYS
	cout << "Airline Name:" << endl;
	cin >> name;
	cout << "Airline Flight Number:" << endl;
	cin >> flightnumber;
	cout << "Destination:" << endl;
	cin >> destination;
	cout << "Passenger Load:" << endl;
	cin >> passengercount;
	passengercheck();
	}

	if (choice == '2')//PRINT FLIGHT REPORT OF UP TO 6 FLIGHTS BY AIRLINE ALPHABETICALLY
	{
		cout << "Airline Name" << "     " << "Flight number" << "     " << "Destination" << "     " << "Passenger Load" << endl;


		cout << "END of Passenger Report" << endl;
		cout << endl;
	}

	if (choice == '3')//PRINT FLIGHT REPORT OF UP TO 6 FLIGHTS BY DESTINATION ALPHABETICALLY
	{
		totalpassengers=totalpassengers+passengercount;

		cout << "Airline Name" << "     " << "Flight number" << "     " << "Destination" << "     " << "Passenger Load" << endl;

		cout << "Total Passengers: " << totalpassengers << endl;
		cout << "End of Passenger Report" << endl;
		cout << endl;
		
	}

	if (choice == '4')
	{
		cout << "Goodbye!" << endl;
	}
}

void passengercheck()
{
	while (passengercount > 275 || passengercount < 50)
	{
		cout << "Incorrect Passenger Load [50-275]" << endl;
		cin >> passengercount;
	}
	
}
Last edited on
really no one ??? :(
It would probably help if you asked a question or at least told us what is wrong with your current code.

For some reason GCC compiles this code.
g++ -Wall -Wextra -pedantic -pedantic-errors -std=c++17

VS 2015 reports "count" is ambiguous on line 37 and 38

Clang reports even more problems:
Main.cpp:10:6: warning: no previous extern declaration for non-static variable 'choice'
      [-Wmissing-variable-declarations]
char choice;
     ^
Main.cpp:11:8: warning: no previous extern declaration for non-static variable 'name' [-Wmissing-variable-declarations]
string name, destination;
       ^
Main.cpp:11:8: warning: declaration requires an exit-time destructor [-Wexit-time-destructors]
Main.cpp:11:8: warning: declaration requires a global destructor [-Wglobal-constructors]
Main.cpp:11:14: warning: no previous extern declaration for non-static variable 'destination'
      [-Wmissing-variable-declarations]
string name, destination;
             ^
Main.cpp:11:14: warning: declaration requires an exit-time destructor [-Wexit-time-destructors]
Main.cpp:11:14: warning: declaration requires a global destructor [-Wglobal-constructors]
Main.cpp:12:8: warning: no previous extern declaration for non-static variable 'count' [-Wmissing-variable-declarations]

double count = 1, flightnumber, passengercount, totalpassengers = 0;
       ^
Main.cpp:12:19: warning: no previous extern declaration for non-static variable 'flightnumber'
      [-Wmissing-variable-declarations]
double count = 1, flightnumber, passengercount, totalpassengers = 0;
                  ^
Main.cpp:12:33: warning: no previous extern declaration for non-static variable 'passengercount'
      [-Wmissing-variable-declarations]
double count = 1, flightnumber, passengercount, totalpassengers = 0;
                                ^
Main.cpp:12:49: warning: no previous extern declaration for non-static variable 'totalpassengers'
      [-Wmissing-variable-declarations]
double count = 1, flightnumber, passengercount, totalpassengers = 0;
                                                ^
Main.cpp:38:35: error: reference to 'count' is ambiguous
    cout << "Charter number: " << count << endl;
                                  ^
Main.cpp:12:8: note: candidate found by name lookup is 'count'
double count = 1, flightnumber, passengercount, totalpassengers = 0;
       ^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:3318:3: note: candidate found by name lookup is
      'std::count'
                count(_InIt _First, _InIt _Last, const _Ty& _Val)
                ^
Main.cpp:39:5: error: reference to 'count' is ambiguous
    count++;
    ^
Main.cpp:12:8: note: candidate found by name lookup is 'count'
double count = 1, flightnumber, passengercount, totalpassengers = 0;
       ^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:3318:3: note: candidate found by name lookup is
      'std::count'
                count(_InIt _First, _InIt _Last, const _Ty& _Val)
                ^
Main.cpp:88:2: warning: C++98 requires newline at end of file [-Wc++98-compat-pedantic]
}
 ^
12 warnings and 2 errors generated.
Press any key to continue . . .
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:3318:3: note: candidate found by name lookup is
'std::count'
count(_InIt _First, _InIt _Last, const _Ty& _Val)
^
Main.cpp:39:5: error: reference to 'count' is ambiguous
count++;
^
Main.cpp:12:8: note: candidate found by name lookup is 'count'
double count = 1, flightnumber, passengercount, totalpassengers = 0;
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:3318:3: note: candidate found by name lookup is
'std::count'
count(_InIt _First, _InIt _Last, const _Ty& _Val)


So that one is a good reason for austin9398 not to have using namespace std; std::count is the STL algorithm, looks like it is somehow included by a microsoft header.

What happens if the global variables are removed? For austin9398 it is bad practise for beginners to have global variables, unless you know what you are doing.

So here I am saying the same things again, From Feb 8:

http://www.cplusplus.com/forum/general/229947/#msg1041863

Have you been at this for 5 weeks, or are you messing with us?
Last edited on
Topic archived. No new replies allowed.