can't run my program
| DUDEMAN (2) | |||
| guys there is something wrong with my code and i cant find what. can you help #include<iostream> using namespace std; int main(void) { system("TITLE Ellis Kenyo's Calculator"); system("COLOR 3A"); char eChar; double dfirstnumber; double dsecondnumber; char cDoagain; do { system("CLS"); cout << "plese enter the first number you would like to use"<< endl; cin >> dfirstnumber; cout << "please enter the operation you would like to complete" << "(+,-,* or /)" << endl; cin >> eChar; cout << "please enter the second number you would like to use" << endl; switch (eChar)( case (+) ; cout << "The answer is: " << dfirstnumber << " + " << dsecondnumber << "=" << (dfirstnumber + dsecondnumber) << endl; break; case " - "; cout << "The answer is: " << dfirstnumber << " - " << dsecondnumber << "=" << (dfirstnumber - dsecondnumber) << endl; break; case " * "; cout << "The answer is: " << dfirstnumber << " * " << dsecondnumber << "=" << (dfirstnumber * dsecondnumber) << endl; break; case"x"; cout << "The answer is: " << dfirstnumber << " x " << dsecondnumber << "=" << (dfirstnumber * dsecondnumber) << endl; break; case"X"; cout << "The answer is: " << dfirstnumber << " X " << dsecondnumber << "=" << (dfirstnumber + dsecondnumber) << endl; break; case"/"; if (dsecondnumber == 0) ( cout << "that is an invalid operation" << endl; )else( cout << "The answer is: " << dfirstnumber << " / " << dsecondnumber << "=" << (dfirstnumber / dsecondnumber) << endl; ) break; default; cout << "that is an invalid operation" <<endl; break; ) cout << "Would you like to strt again? (y or n)" endl; cin >> cDoagain; )while (cDoagain == 'Y' || cDoagain =='y'); system ("PAUSE"); return 0; ) there is apparantly something wrong with the "case" function. please help | |||
| Mitsakos (343) | |||
| All your cases are wrong... You should open and close brackets {} not parenthesis... And your cases from
case (+) ;should be
case '+' : The same thing for all the other cases... (You must replace the double quotes with single ones since you have chars) | |||
| DUDEMAN (2) | |||
| tyvm its my 1st day programming and im a bit nooby lol | |||
This topic is archived - New replies not allowed.
