Need advice on nested if-else statements

Can someone please help me figure out the error? After I input the number of wheels, if it is greater than two, then I want it to go to the statement asking how many passengers it holds, but no matter what number you input, it always goes directly to the statements for if it has only two wheels. I think the problem might have something to do with the brackets, but if I try changing them, it just creates another error. Any advice would be much appreciated.

#include <iostream>
#include <cstdlib>

using namespace std;

int main () {

char engine;
int numOfWheels;
int passengers;
char repeatAnswer;
bool repeat=true;

while (repeat) {
cout<<"Vehicle Classification" <<endl
<<"----------------------" <<endl
<<"Is there an engine? (Y/N) ";
cin>>engine;
if (engine=='Y'|| engine=='y') {
cout<<"Answer: The vehicle has an engine." <<endl
<<"How many wheels does the vehicle have? ";
cin>> numOfWheels;
if (numOfWheels=2) {
cout<<"Answer: The vehicle has " <<numOfWheels <<" wheel(s)." <<endl
<<"The vehicle is a motorcycle." <<endl;
}else if (numOfWheels>2) {
cout<<"Answer: The vehicle has " <<numOfWheels <<" wheel(s)." <<endl
<<"How many passengers can fit into the vehicle? ";
cin>>passengers;
if (passengers<=5) {
cout<<"Answer: The vehicle can fit " <<passengers <<" people." <<endl
<<"The vehicle is a car." <<endl;
}else if (6<=passengers<=9) {
cout<<"Answer: The vehicle can fit " <<passengers <<"people." <<endl
<<"The vehicle is a van." <<endl;
}else if (passengers>9) {
cout<<"Answer: The vehicle can fit " <<passengers <<"people." <<endl
<<"The vehicle is a bus." <<endl;
}
}
}else if (engine=='N'||engine=='n') {
cout<<"Answer: The vehicle does not have an engine." <<endl
<<"How many wheels does the vehicle have? ";
cin>> numOfWheels;
if (numOfWheels==1) {
cout<<"Answer: The vehicle has 1 wheel." <<endl
<<"The vehicle is a unicycle." <<endl;
}else if (numOfWheels==2) {
cout<<"Answer: The vehicle has 2 wheels." <<endl
<<"The vehicle is a bicycle." <<endl;
}
}

cout<<"Do you wish to try again? (Y/N) ";
cin>> repeatAnswer;

if (repeatAnswer=='Y'||repeatAnswer=='y') {
repeat=true;
}else if (repeatAnswer=='N'||repeatAnswer=='n') {
repeat=false;
}

}

system ("pause");
return 0;
}
Use == instead of = for your if statement. And [code][/code] tags.
Topic archived. No new replies allowed.