Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

First calc script


eltony
 Share

Recommended Posts

every time i tried to compile it i get an error omg it deals with the cout << "please enter the second number ect. i tried so much to figure it out i put up just in case some body out there might have a clue.

```
#include using namespace std;

int main(void)
{

    system("TITLE Calculator");
    system("COLOR 2");
    char cChar;
    double dfirstnumber;
    double dsecondnumber;
    char cdoagain;

    do
    {
        system("CLS");
        cout << "please enter the first number that you would like to use"
            << endl;
        cin >> dfirstnumber;
        cout << "please enter the operation that you would like to complete"
            << " (+,-,* or /)" << endl;
        cin >> cChar

        cout << "please enter the second number you would like to use"
            << endl;

        Switch (cChar)
        {
        case '+':
            cout << " The answer is: " << dfirstnumber << " + " <<
                dsecondnumber << " = " << (dfirstnumber + dsencondnumber)
                << endl;
            break;
        case '-':
            cout << " The answer is: " << dfirstnumber << " - " <<
                desencondnumber << " = " << (dfirstnumber - dsecondnumber)
                << endl;
            break;
        case '*':
            cout << " The answer is: " << dfirstnumber << " * " <<
                dsencondnumber << " = " << (dfirsnumber * dsencondnumber)
                << endl;
              break;
        case 'x':
            cout << " The answer is: " << dfirstnumber << " x " <<
                dsencondnumber << " = " (dfirstnumber x dsencondnumber)
                << endl;
              break;
        case 'X':
            cout << " The answer is: " << dfirstnumber << " X " <<
                dsencondnumber << " = " (dfirstnumber X dsencondnumber)
                << endl;   
              break;   
        case '/':
            if(dsecondnumber == 0) {
                cout << " That is an invalid operation" << endl;
            )else{
            cout << " The answer is: " << dfirstnumber << " x " <<
                dsencondnumber << " = " (dfirstnumber x dsencondnumber)
                << endl;
            }
            break;
        default:
            cout << "That is an invalid operation" << endl;
            break;
        }
        cout << "would you like to start again? ( y or n)" << enld;
        cin >> cDoagain;
    }while (cDoagain == 'Y' or cDogain == 'y');
    system("PAUSE") ;
    return 0;
    }

```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...