C++ Console app "Calculator" syntax error!
Posted: Tue Dec 15, 2009 9:37 pm
I get this error when debugging my program - (69) : error C2059: syntax error : '}' (btw i think line 69 = last line)
Here is my code(new to programming)! please help! - written in c++ console
Here is my code(new to programming)! please help! - written in c++ console
Code: Select all
#include <iostream>
using namespace std;
int main(void)
{
system("TITLE Calculator");
system("Color 2");
char cChar;
double dfirstnumber;
double dsecondnumber;
char cDoagain;
do
{
system("CLS");
cout << "Enter your first number: " << endl;
cin >> dfirstnumber;
cout << "Enter the operation you want to complete: " << " (+,-,*, or /)" << endl;
cin >> cChar;
cout << "Enter your second number" << endl;
switch (cChar)
{
case '+':
cout << "Answer: " << dfirstnumber << " + " << dsecondnumber << " = " << (dfirstnumber + dsecondnumber) << endl;
break;
case '-':
cout << "Answer: " << dfirstnumber << " - " << dsecondnumber << " = " << (dfirstnumber - dsecondnumber) << endl;
break;
case '*':
cout << "Answer: " << dfirstnumber << " * " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
case 'X':
cout << "Answer: " << dfirstnumber << " X " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
case 'x':
cout << "Answer: " << dfirstnumber << " x " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
break;
case '/':
if(dsecondnumber == 0){
cout << " Invalid Operation! " << endl;
} else {
cout << "Answer: " << dfirstnumber << " / " << dsecondnumber << " = " << (dfirstnumber / dsecondnumber) << endl;
break;
}
break;
default:
cout << "Invalid Operation! " << endl;
break;
cout << "Would you like to reset? (Y/N)" << endl;
cin >> cDoagain;
}
{while (cDoagain == 'Y' || cDoagain == 'y');
system("Pause");
return 0;
}
}
}