all of the underlined peices of code say this"expected ; before string constant"
how do i fix that -thanks,moot
using namespace std;
int main(){
char cchar;
double dnumber1;
double dnumber2;
do{
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;
switch (cchar){
case '+': cout << "the answer is: " << dnumber1 " + " << dnumber2 " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-': cout << "the answer is: " << dnumber1 " - " << dnumber2 " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*': cout << "the answer is: " << dnumber1 " * " << dnumber2 " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/': cout << "the answer is: " << dnumber1 " / " << dnumber2 " = "
<< (dnumber1 / dnumber2) << endl;
break;
}
system("pause");
return 0;
}
ok now all of the errors are on the last line, the underlined 1
and where do i put a "}" for the do statement
int main(){
char cchar;
double dnumber1;
double dnumber2;
do{
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;
switch (cchar){
case '+':
cout << "the answer is: " << dnumber1 << " + " << dnumber2 << " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-':
cout << "the answer is: " << dnumber1 << " - " << dnumber2 << " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*':
cout << "the answer is: " << dnumber1 << " * " << dnumber2 << " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/':
cout << "the answer is: " << dnumber1 << " / " << dnumber2 << " = "
<< (dnumber1 / dnumber2) << endl;
break;
}
system("pause");
return 0; }
system("CLS");
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;
switch (cchar){
case '+':
cout << "the answer is: " << dnumber1 << " + " << dnumber2 << " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-':
cout << "the answer is: " << dnumber1 << " - " << dnumber2 << " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*':
cout << "the answer is: " << dnumber1 << " * " << dnumber2 << " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/':
cout << "the answer is: " << dnumber1 << " / " << dnumber2 << " = "
<< (dnumber1 / dnumber2) << endl;
break;
}
cout << "would you like to start again (y or n)";
cin >> cagain; }while (cagain = 'y' || cagain = 'Y');