View Single Post
Old 12-10-2010, 05:52 PM   #3
The Fifth Horseman
FUTURE SCIENCE BASTARD
 
The Fifth Horseman's Avatar


 
Join Date: Oct 2004
Location: Opole, Poland
Posts: 14,276
Default

Quick and dirty fix just to get it working:
Code:
#include <iostream>
using namespace std;

int main()
{
system("TITLE Calculator");
system("COLOR 2");
char cChar, cDoagain; // char is a character, its how you get plus and minus signs, etc //
double dfirstnumber, dsecondnumber;

do { system ("CLS");
     cout << "please enter the first number that you would like to use\n";
     cin >> firstnumber >> secondnumber;
     cout << "please enter the operation that you want to complete: (+,-,*, or /)\n";
     cin >> cChar;
     switch (cChar){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 start again? (y or n)" << endl;
     cin >> cDoagain; } while (cDoagain == 'Y' || cDoagain == 'y');
     system("PAUSE"); }
__________________

"God. Can't you people see I'm trying to commit a crime against science and nature here?"
-- Reed Richards

Last edited by The Fifth Horseman; 12-10-2010 at 06:17 PM.
The Fifth Horseman is offline                         Send a private message to The Fifth Horseman
Reply With Quote