ios - else if expected expression c++ / Xcode -
i have seen problem around forum have not been able fix issue. after "else if" xcode can't compile, tells me "parse issue" , requieres "expected expression".
i know beginner's question want understand wrong code, why keeps telling me expected expression after each esle if...
if (typestrat == 1) { cout << "quel est le prix d'exercice du long call ?" << endl; cin >> k1; cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixcall(s,k,t,r,v) + bsprixput(s,k,t,r,v)) << endl; cout << "delta " << (bsdeltacall(s,k,t,r,v) + bsdeltaput(s,k,t,r,v)) << endl; cout << "vega " << (2*bsvega(s,k,t,r,v)) << endl; cout << "rho " << (bsrhocall(s,k,t,r,v) + bsrhoput(s,k,t,r,v)) << endl; cout << "theta " << (bsthetacall(s,k,t,r,v)/365.0) + (bsthetaput(s,k,t,r,v)/365.0) << "journalier" << endl; else if (typestrat == 2) { cout << "quel est le prix d'exercice du long call ?" << endl; cin >> k1; cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixcall(s,k1,t,r,v) + bsprixput(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltacall(s,k1,t,r,v) + bsdeltaput(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) + bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhocall(s,k1,t,r,v) + bsrhoput(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetacall(s,k1,t,r,v)/365.0) + (bsthetaput(s,k2,t,r,v)/365.0) << "journalier" << endl; } else if (typestrat == 3) { cout << "quel est le prix d'exercice du long call ?" << endl; cin >> k1; cout << "quel est le prix d'exercice du short call ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixcall(s,k1,t,r,v) - bsprixcall(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltacall(s,k1,t,r,v) - bsdeltacall(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) - bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhocall(s,k1,t,r,v) - bsrhocall(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetacall(s,k1,t,r,v)/365.0) - (bsthetacall(s,k2,t,r,v)/365.0) << "journalier" << endl; } else if (typestrat == 4) { cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k1; cout << "quel est le prix d'exercice du short put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixput(s,k1,t,r,v) - bsprixput(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltaput(s,k1,t,r,v) - bsdeltaput(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) - bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhoput(s,k1,t,r,v) - bsrhoput(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetaput(s,k1,t,r,v)/365.0) - (bsthetaput(s,k2,t,r,v)/365.0) << "journalier" << endl; } else if (typestrat == 5) { cout << "quel est le prix d'exercice du long call ?" << endl; cin >> k1; cout << "quel est le prix d'exercice des deux short call ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixcall(s,k1,t,r,v) - 2*bsprixcall(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltacall(s,k1,t,r,v) - 2*bsdeltacall(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) - 2*bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhocall(s,k1,t,r,v) - 2*bsrhocall(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetacall(s,k1,t,r,v)/365.0) - 2*(bsthetacall(s,k2,t,r,v)/365.0) << "journalier" << endl; } else if (typestrat == 6) { cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k1; cout << "quel est le prix d'exercice des deux short put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixput(s,k1,t,r,v) - 2*bsprixput(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltaput(s,k1,t,r,v) - 2*bsdeltaput(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) - 2*bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhoput(s,k1,t,r,v) - 2*bsrhoput(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetaput(s,k1,t,r,v)/365.0) - 2*(bsthetaput(s,k2,t,r,v)/365.0) << "journalier" << endl; } }
an else if
requires preceding if
statement. block of if
statement precedes first else if
not closed, i.e. ending curly brace }
missing. also, there }
in end.
missing curly brace:
if (typestrat == 1) { cout << "quel est le prix d'exercice du long call ?" << endl; cin >> k1; cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixcall(s,k,t,r,v) + bsprixput(s,k,t,r,v)) << endl; cout << "delta " << (bsdeltacall(s,k,t,r,v) + bsdeltaput(s,k,t,r,v)) << endl; cout << "vega " << (2*bsvega(s,k,t,r,v)) << endl; cout << "rho " << (bsrhocall(s,k,t,r,v) + bsrhoput(s,k,t,r,v)) << endl; cout << "theta " << (bsthetacall(s,k,t,r,v)/365.0) + (bsthetaput(s,k,t,r,v)/365.0) << "journalier" << endl; // } <-- insert ending curly brace here else if (typestrat == 2)
extra curly brace:
else if (typestrat == 6) { cout << "quel est le prix d'exercice du long put ?" << endl; cin >> k1; cout << "quel est le prix d'exercice des deux short put ?" << endl; cin >> k2; cout << "prix de la stratégie " << (bsprixput(s,k1,t,r,v) - 2*bsprixput(s,k2,t,r,v)) << endl; cout << "delta " << (bsdeltaput(s,k1,t,r,v) - 2*bsdeltaput(s,k2,t,r,v)) << endl; cout << "vega " << (bsvega(s,k1,t,r,v) - 2*bsvega(s,k2,t,r,v)) << endl; cout << "rho " << (bsrhoput(s,k1,t,r,v) - 2*bsrhoput(s,k2,t,r,v)) << endl; cout << "theta " << (bsthetaput(s,k1,t,r,v)/365.0) - 2*(bsthetaput(s,k2,t,r,v)/365.0) << "journalier" << endl; } } // <-- remove curly brace
Comments
Post a Comment