Need help with Error

I need to make a program that takes user input and check for errors after all the data has been entered, I keep getting an error on line 37 : error: no match for 'operator>=' in 'airline >=3'
for 'operator>=' in 'destination >=5'
for 'operator>=' in 'airISO >=5'
if someone could help me fix this problem or just point in the correct direction I would it.

#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
string airLine; //will be used to store complete airline name not ISO code
string destination; // Starting point to final destination
string airIso; // holds ISO code for airline as well as flight #
double tripMiles = 0.0; //will hold miles for individual trips
double tripCost = 0; //will hold cost for individual trips
double totalCost = 0; //will add prices from trips
double totalMiles = 0; //will add all miles from trips

cout <<"What airline will you be using?\n";
getline(cin, airLine);

//asking for origin and detination
cout <<"Enter point of origin and destination\n";
getline(cin, destination);

//ask for airline ISO code and flight #
cout <<"Enter airlines ISO code and flight number\n";
getline(cin, airIso);

//ask for miles traveled
cout <<"Enter miles traveled\n";
cin >> tripMiles;

//ask for price of ticket
cout <<"Enter cost of ticket\n";
cin >> tripCost;

if((airLine >= 3) && (destination >= 5) && (airIso >=5) && (tripMiles >= 100.0) &&(tripCost >=10.00))
cout << "continue.\n";
else
cout << "Error.\n";

system("pause");
return 0;
}








Last edited on
1
2
string airLine; //will be used to store complete airline name 
if((airLine >= 3) ... etc. ...


How does comparing the complete airline name with the integer 3 make sense?

Was it perhaps the length of the string which was intended, or something else?
Last edited on
Hi Chervil,

Thank you for your reply! So, basically what this program needs to do, on 3 separate occasions, is to ask the user for information, once the user submits all the data, the program will then do a simple check of this data. For example- the user should input a complete name of an airline, this could be a fictional or a real Airline, but the name has to have more than 3 characters
1
2
:  cout <<"What airline will you be using?\n";
getline(cin, airLine);


If the data is "correct" according to our parameters, the program should then save tripMiles; as well as tripCost to totalCost and totalMiles.

Once that is completed, the user will have to answer the questions again, they can use the same or information. the prgram will check again for errors, if none are found we need to add the new values from tripMiles; and tripCost to totalCost and totalMiles.

This process will be repeated once more (users data/ checking for errors). Again taking the new values from tripMiles; and tripCost to totalCost and totalMiles.

the final step will be to average the cost per mile using data from the previous steps.

Thanks for the clarification.
The length, which is what you need, to see whether there are at least three characters, can be found using either .size() or .length()
if (airLine.size() >= 3)
or
if (airIso.length() >= 5)
and so on.

Hope this helps you to get a bit further with this now.

http://www.cplusplus.com/reference/string/string/size/
Last edited on
Thank you very much, you have pointed me in the right direction.

Cheers
Topic archived. No new replies allowed.