Monday, May 24, 2010

If anyone has any experience with programming, specifically C++, can you help me with a simple script error?

Ok, so my calculator script works at first, when it asks for 1 number, then when it asks if I should add, subtract, etc, the second number is automatically set to a whack number. please help :D





My script (first part, i think the error is at the end, plus I just copy and pasted my script over for -, *, and /):


#include%26lt;iostream%26gt;


using namespace std;





int main(void)


{





system("TITLE My little Calcy, FO");


system("COLOR 2");


char cChar;


double dfirstnumber;


double dsecondnumber;


char cDoagain;





do


{





system("CLS");


cout %26lt;%26lt; "Insert the first number"


%26lt;%26lt; endl;


cin %26gt;%26gt; dfirstnumber;


cout %26lt;%26lt; "Enter the operation you would like to complete"


%26lt;%26lt; " (+,-,*, or /)" %26lt;%26lt; endl;


cin %26gt;%26gt; cChar;





cout %26lt;%26lt; "Enter 2nd number, hurry up also, I don't have all day"


%26lt;%26lt; endl;





switch (cChar)


{


case '+' :


cout %26lt;%26lt; "The answer is..." %26lt;%26lt; dfirstnumber %26lt;%26lt; " + " %26lt;%26lt; dsecondnumber %26lt;%26lt; " = " %26lt;%26lt; (dfirstnumber + dsecondnumber)


%26lt;%26lt; endl;


break;

If anyone has any experience with programming, specifically C++, can you help me with a simple script error?
When you asked for the second number, you forgot to read in their answer? cin %26gt;%26gt; dsecondnumber?

email cards

No comments:

Post a Comment