hi, guys i'm in colleage trying to do some homework with cs10 and got stuck with this combination of functions please help me out!!!! T^T spent 8hours today still couldn't figure it out

#include<iostream>
using namespace std;

void getProbsPerSet();
void doOneset(char Func);
void doOneproblem(int &Answer);
void getMaxnumber(int &MAX);
void printHeader(int &First, int &Sec, char Func);
void calculateCorrectAnswer(int First, int Sec, char Func, int &Cor);
void checkAnswer(int Ans, int Cor);

int main()
{
    char Func;
    //srand(static_cast<unsigned>(time(0)));    <<Not sure what this is suppose to do with
    doOneset('+');
    doOneset('-');
    doOneset('*');

    system("pause");
    return 0;
}

void doOneset(char Func) {

    getProbsPerSet() {  // keep saying expected ';' not sure why
        printHeader(&First, &Sec, Func); // all of line 27 - 30  they can't declared not sure how to fix this 
        doOneproblem(&Ans);
        getMaxnumber(&Max);
        checkAnswer(Ans, Cor);
    }

}

void getProbsPerSet() {
    int i;
    for (i = 0; i < 5; i++) {
        doOneset(Func);
    }
}

void doOneproblem(int &Ans) {

    cin >> Ans;
    cout << endl;
}

void printHeader(int &First, int &Sec, char Func) {

}

void getMaxnumber(int First, int Sec, char Func, int &Max) {
    if (Func == '+') {
        Max = First + Sec;
    }
    if (Func == '-') {
        Max = First - Sec;
    }
    if (Func == '*') {
        Max = First * Sec;
    }
}

void calculateCorrectAnswer(int First, int Sec, char Func, int &Cor) {
    if (Func == '+') {
        Cor = First + Sec;
    }
    if (Func == '-') {
        Cor = First - Sec;
    }
    if (Func == '*') {
        Cor = First * Sec;
    }
}

void checkAnswer(int Ans, int Cor) {
    if (Ans == Cor) {
        cout << "Correct" << endl;
    }
    else {
        cout << "Incorrect" << endl;

    }
}

The Picture is description what my professor asking for this homework and the result should looks like

45 + 21 = 66
correct
0 + 100 = 100    
correct
54 + 23 = 67
incorrect
4 + 19 = 13
incorrect
18 + 92 = 100    
correct
59 - 19 = 40
correct
19 - 84 = -29    
incorrect
0 - 65 = -65
correct
96 - 1 = 95
correct
94 - 14 = 80
correct
0 * 87 = 0
correct
45 * 84 = 398
incorrect
8 * 37 = 873
incorrect
34 * 83 = 831
incorrect
38 * 3 = 238
incorrect

this. I already programed without using functions it worked fine but i tried separate with these functions having so much trouble with please help me out!!! THANKS

Attachments 222.jpg 45.44 KB

Bookmark this site:
http://www.cplusplus.com

All the standard C++ libraries
http://www.cplusplus.com/reference

Line 15: Uncomment to "seed" the random number generator with the program's current time. You'll need the srand function from the cstdlib library:
http://www.cplusplus.com/reference/cstdlib/
http://www.cplusplus.com/reference/cstdlib/srand/ (see the example)

You are also using "time", so you'll need ctime.
http://www.cplusplus.com/reference/ctime/
http://www.cplusplus.com/reference/ctime/time/

So add these lines between lines 1 and 2:

#include <cstdlib>
#include <ctime>

All the above makes your random numbers more random. Note for your line 2, I've never used a static cast with this. The example that I sited does not use it either. However, if your professor told you to use the line as-is, then use the line as-is. If it works, go with it.

Now for lines 24 to 33. You seem to be having a function WITHIN a function (you have those brackets on lines 26 and 31 for no apparent reason, so that tells me you are confused. Delete the brackets on lines 26 and line 31. They serve no purpose and just confuse everything. Technically those brackets are not a problem, but it's quite clear that they are not doing what you think they are doing, so delete them. As for the semicolon on line 26, you need one. So so far, change lines 24 to 33 to this (note, not done yet by a long shot).

void doOneset(char Func) 
{
        getProbsPerSet();
        printHeader(&First, &Sec, Func); 
        doOneproblem(&Ans);
        getMaxnumber(&Max);
        checkAnswer(Ans, Cor);
}

All those & symbols need to go. They belong in the function declarations, but not within the body of the function definition/implementation. The & means "pass by reference". Put this assignment aside and look at this tutorial.

http://www.cplusplus.com/doc/tutorial/functions/

From the top of your program...

void doOneproblem(int &Answer); // <-- & here is OK

void doOneset(char Func)
{
        getProbsPerSet();
        printHeader(First, Sec, Func); 
        doOneproblem(&Ans);  // <-- Get rid of & in the function CALL
        getMaxnumber(&Max);  // <-- Get rid of & in the function CALL
        checkAnswer(Ans, Cor);
}

They have some examples in the tutorial linked. Copy that format. Scroll to the "Arguments passed by value and by reference" section. There are more problems with this function.

getMaxNumber: This function doesn't match what you have at the top oof the program. What is this function supposed to do?

You say that you have it all working WITHOUT the functions. I imgaine the assignment requires that you take THAT code, which I assume is all in main, and try putting it into functions ONE FUNCTION AT A TIME. You're doing it all at once. Too much. Thus I would write doOneProblem BEFORE writing doOneSet. And I'd write the three functions that are below doOneProblem before writing doOneProblem. I imagine you'll be calling those three functions FROM doOneProblem, if I'm reading the graph right. You've been given a graph of what functions get called by what functions. Make the function calls match the graph.