Hey, this is my first post, and I am a beginner programmer, just started learning C++ a week ago. This is my first program, but i can not tell what is wrong...
Objective:
make a menu
user types number
runs program
***returns to menu (how do i do this?)
My Error/s:
I had them all (IF... IF.... IF....) and whatever value I put in the menu, it would only display the first one (addition). I changed it to (IF... ELSE IF.... ELSE IF...) and now i cant compile, because i have errors... (expected primary expression before "else" and expected ";" before "else") for each place where i have ELSE IF...
this is my code...
I Appreciate the HELP!Code://Mathematics //Library #include <iostream> #include <iomanip> #include <conio.h> #include <cstdio> #include <cmath> //Const //Var using namespace std; double ratep, rate, principle, years, x, x1, x2, x3, y, y2, y3, y4, z, z1, z2, z3; int X; //Main int main () { cout << "######## Mathematics ########" << endl; cout << "(C) 2010-2011" << endl; cout << " " << endl; cout << "Type The Number and Press Enter..." << endl; cout << " " << endl; cout << "(1): Addition" << endl; cout << "(2): Subtraction" << endl; cout << "(3): Multiplication" << endl; cout << "(4): Division" << endl; cout << "(5): Simple Interest Calculator" << endl; cout << "(6): Credits" << endl; cout << "(7): Quit" << endl; cin >> X; if (X==1); { //Addition cout << " " << endl; cout << "Addition" << endl; cout << "X+Y=Z" << endl; cout << "What is X?" << endl; cin >> x; cout << "What is Y?" << endl; cin >> y; double z (x+y); cout << "Z equals to " << z << endl; cin.get(); cin.get(); return(0); }; else if (X==2); { //Subtraction cout << " " << endl; cout << "Subtraction" << endl; cout << "X-Y=Z" << endl; cout << "What is X?" << endl; cin >> x1; cout << "What is Y?" << endl; cin >> y2; double z1 (x1-y2); cout << "Z equals to " << z1 << endl; cin.get(); cin.get(); return(0); }; else if (X==3); { //Multiplication cout << " " << endl; cout << "Multiplication" << endl; cout << "X*Y=Z" << endl; cout << "What is X?" << endl; cin >> x2; cout << "What is Y?" << endl; cin >> y3; double z2 (x2*y3); cout << "Z equals to " << z2 << endl; cin.get(); cin.get(); return(0); }; else if (X==4); { //Division cout << " " << endl; cout << "Division" << endl; cout << "X/Y=Z" << endl; cout << "What is X?" << endl; cin >> x3; cout << "What is Y?" << endl; cin >> y4 double z3 (x3/y4); cout << "Z equals to " << z3 << endl; cin.get(); cin.get(); return(0); }; else if (X==5); { //Simple Interest Calculator cout << " " << endl; cout << "Interest Calculator-Simple" << endl; cout << "What is the Principle? ($)" <<endl; cin >> principle; cout << "What is the Rate? (%)" << endl; cin >> ratep; double rate = (1+(ratep/100)); cout << "What is the rate of time? (Years)" << endl; cin >> years; cout << "The New Value of $" << principle << " at " << ratep << "% after " << years << " years:" << endl; cout << principle*rate*years << endl; cin.get(); cin.get(); return(0); }; else if (X==6); { //Credits cout << " " << endl; cout << "Mathematics" << endl; cout << "(c) 2010-2011" << endl; cin.get(); cin.get(); return(0); }; else if (X==7); { //Exit cout << "Terminating Program" << endl; cout << "Mathematics" << endl; cout << "(c) 2010-2011" << endl; cin.get(); cin.get(); return(0); }; };



LinkBack URL
About LinkBacks



