Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I did not include any random functions and it still returns a random number at the end of the program. Please help. This is a math calculator that can do basic math operations.

C++
#include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 

    using namespace std;

    string play_again;

    void wait ( double seconds )
    {
      clock_t endwait;
      endwait = clock () + seconds * CLOCKS_PER_SEC ;
      while (clock() > x;
      cout > y;
      cout > x;
      cout > y;
      cout > x;
      cout > y;
      cout > x;
      cout > y;
      cout > ans;
      if(ans == 'M') {
        
        multiply(num1, num2);
      } else if(ans == 'D') {

        divide(num1, num2);
      } else if(ans == 'S') {

        subtract(num1, num2);
      } else if(ans == 'A') {

        add(num1, num2);
      } else {

        cout > play_again;
      if (play_again == "Y") {

        askMathFunction();
      } else if (play_again == "N") {

        cout<< load("Logging out");
        return 0;
      } else {

        cout<< "Please enter something..."<< endl;
        playagain();
      }
    }

    int main( ){
      load("Loading");
      cout << "Calculator starting... " << std::endl;
      cout << "Press ENTER to start" << std::endl;
      cin.ignore();
      askMathFunction();
      playagain();
      while(play_again == "Y") {

        playagain();
      }
        
      return 0;
    }


What I have tried:

1. I have tried re-writing the program.
2. I have tried to change all the values.
Posted
Updated 1-Oct-18 23:21pm
v2

That code won't compile: the function you call several times playagain isn't there, nor is askMathFunction
If your code doesn't compile cleanly, then it doesn't produce an EXE file, and you can't execute it.

So the version of code you are testing is not the same as the code you are looking at, and any results it produces are pretty much worthless!
 
Share this answer
 
You have lots of #include statements that do nothing. You have lots of cout > y (and other variable names), that also do nothing. I suggest you go back to your documentation and read up on the cin method, passing parameters to functions, including header files, etc., etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900