I have tried checking other answers already, but I still cannot find the answer. I am getting this error:
compilation info
prog.cpp:192:2: error: expected unqualified-id before 'else'
else if (userInput == 3)
^
Here is the line of code:
else if (userInputSolveFor == "t")
{
cout << "You are solving for time." << endl;
cout << endl;
cout << "What is the acceleration (in m/s/s)?" << endl;
cin >> acceleration;
cout << "What is the initial velocity?" << endl;
cin >> initialVelocity;
cout << "What is the distance (in meters)?" << endl;
cin >> deltaDistance;
if (initialVelocity == 0)
{
cout << "The time is " << sqrt(deltaDistance - (0.5 * acceleration)) << setprecision(10) << " seconds." << endl;
}
else if (acceleration == 0)
{
cout << "The time is " << (deltaDistance / initialVelocity) << setprecision(10) << " seconds." << endl;
}
else
{
cout << "The input you have entered is not valid." << endl;
}
}
}
else
{
cout << "The input you have entered is not valid." << endl;
}
}
else if (userInput == 3)
{
cout << "You are using vf^2 = vi^2 + 2(a)(x)." << endl;
cout << endl;
cout << "What are you trying to solve for?" <<endl;
cout << endl;
cout << "Use vf for final velocity (in m/s)." << endl;
cout << "Use vi for initial velocity (in m/s)." << endl;
cout << "Use a for acceleration." << endl;
cout << "Use x for distance (in meters)." <<endl;
cin >> userInputSolveFor;
cout << endl;
Where line 192 is "else if (userInput == 3)"
I don't know what to do. I have tried adding/removing "}" and I get 15+ errors when I change a single brace so I don't think that is the problem.
Aucun commentaire:
Enregistrer un commentaire