Need Help finishing school project.

I need help finishing this school project. I've been trying to work around the problems but I just keep going in circles.

My Code is the following:

# include <iostream>
# include <cmath>
# include <iomanip>
# include <ctime>
int randValue( int level );
int generateProblem( int option, int level );
void arithmetic( int option, int level );
void correctMessage();
void incorrectMessage();
using namespace std;
int main()
{
int level, option;
int num = rand();
srand((unsigned)time(0));

do
{
do
{
cout<<"Enter the grade-level: ";
cin>>level;
cout<<endl;
if (level < 1 || level > 3)
{
cout<<"Please Enter a level from 1 - 3\n"<<endl;
}
}while (level < 0 || level > 3);
do
{
cout<<"Select an arithmetic operation type: \n1. Addition \n2. Subtraction \n3. Multiplication \n4. Division \n5. Combination of 1 through 4 \n6. Select another level \n7. Exit \n\n";
cin>>option;
cout<<endl;

arithmetic (option, level);

}while (option >=1 && option <= 5);
}while (option = 6);




if (option = 7)
{
cout<<"Good Bye.\n"<<endl;
}

return 0;
}
int randValue (int level)
{
int num = rand();
switch (level)
{
case 1:
num = (rand() % 10);
break;
case 2:
num = (rand() % 100);
break;
case 3:
num = (rand() % 1000);
break;
}

return num;
}
int generateProblem (int option, int level)
{

int num1 = randValue(level);
int num2 = randValue(level);
int num = randValue(level);
num = (rand() %4);

switch (option)
{
case 1:
cout<<"How much is "<<num1<<" + "<<num2<<"?"<<endl;

return num1+num2;
break;
case 2:
cout<<"How much is "<<num1<<" - "<<num2<<"?"<<endl;

return num1-num2;
break;
case 3:
cout<<"How much is "<<num1<<" * "<<num2<<"?"<<endl;

return num1*num2;
break;
case 4:
if(num1 > 0 && num2 > 0)
{
cout<<"How much is "<<num1<<" / "<<num2<<"?"<<endl;
}
return num1/num2;
break;
case 5:
switch(num)
{
case 1:
cout<<"How much is "<<num1<<" + "<<num2<<"?"<<endl;
return num1+num2;
break;
case 2:
cout<<"How much is "<<num1<<" - "<<num2<<"?"<<endl;
return num1-num2;
break;
case 3:
cout<<"How much is "<<num1<<" * "<<num2<<"?"<<endl;
return num1*num2;
break;
case 4:
if(num1 > 0 && num2 > 0)
{
cout<<"How much is "<<num1<<" / "<<num2<<"?"<<endl;
}
return num1/num2;
break;
}

break;

}
return option;
}
void arithmetic (int option, int level)
{
int responce;
int result;

for (int i = 0; i < 5; i=i++)
{
result = generateProblem (option, level);
cin>>responce;
}

}
void correctMessage()
{
int num;
num = rand() %4;

switch(num)
{
case 0:

cout<<"Very Good!"<<endl;
break;

case 1:

cout<<"Excellent!"<<endl;
break;

case 2:

cout<<"Nice Work!"<<endl;
break;

case 3:

cout<<"Keep up the good work!"<<endl;
break;
}

}
void incorrectMessage()
{
int num;
num = (rand() %5);
switch (num)
{
case 0:
cout<<"No sorry."<<endl;
break;
case 1:
cout<<"Sorry, it's wrong."<<endl;
break;
case 2:
cout<<"Don't give up"<<endl;
break;
case 3:
cout<<"It's not the right answer"<<endl;
break;
}


}

And the Output should look like:

Enter the grade-level: 1
1

Select an arithmetic operation type:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Combination of 1 through 4
6. Select another level
7. Exit

1
How much is 3 + 7? 10
Very good!
How much is 1 + 0? 1
Nice work!
How much is 8 + 1? 9
Keep up the good work!
How much is 0 + 5? 5
Very good!
How much is 5 + 7? 12
Excellent!

You have 5 correct answers. You pass.

Select an arithmetic operation type:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Combination of 1 through 4
6. Select another level
7. Exit

5
How much is 4 + 0? 0
Don't give up!
How much is 3 * 8? 2
Sorry. It's wrong.
How much is 5 * 7? 12
No. Sorry.
How much is 0 + 5? 5
Excellent!
How much is 9 - 2? 7
Excellent!

You have 2 correct answers. You do not pass.
Please ask your instructor for extra help.


Select an arithmetic operation type:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Combination of 1 through 4
6. Select another level
7. Exit

6

Enter the grade-level: 2
1

Select an arithmetic operation type:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Combination of 1 through 4
6. Select another level
7. Exit

5
How much is 83 * 59? 1
Don't give up!
How much is 60 * 40? 2
Don't give up!
How much is 2465 / 85? 3
Sorry. It's wrong.
How much is 86 + 94? 180
Nice work!
How much is 90 * 34? 1
Don't give up!

You have 1 correct answers. You do not pass.
Please ask your instructor for extra help.


Select an arithmetic operation type:
1. Addtiion
2. Subtraction
3. Multiplication
4. Division
5. Combination of 1 through 4
6. Select another level
7. Exit

7

Good bye

*What I have problem with is the initial do while loops. its showing the "choose a level" when it shouldn't.

*after you hit 7 to exit the program you have to input another 5 numbers to exit.

* I don't really know how to implement the correctMessage/Wrong Message into the coding so that it displays correctly.

*sometimes after you choose the type of math problem it skips some.

*How to put the % of right and wrong answers so that it tells that he passed or he didn't. (75% of the problems to pass).

Sorry for the Long coding ._. but I really need the help in this one.

Thanks!
[7204 byte] By [Rick2101] at [2007-11-20 11:57:30]
# 1 Re: Need Help finishing school project.
What does this line do?

while (option = 6);

- petter
wildfrog at 2007-11-11 4:02:02 >
# 2 Re: Need Help finishing school project.
Thats supposed to go back and ask for the Level again.
Rick2101 at 2007-11-11 4:03:05 >
# 3 Re: Need Help finishing school project.
But option = 6is an assignment that returns 6, and 6 converts to true.

To compare you need a double ==:

while (option == 6);

- petter
wildfrog at 2007-11-11 4:04:03 >
# 4 Re: Need Help finishing school project.
I think my compiler must have missed that, but It didn't show any error and ran the same with = and ==
Rick2101 at 2007-11-11 4:05:09 >
# 5 Re: Need Help finishing school project.
I think my compiler must have missed that, but It didn't show any error and ran the same with = and ==Both are valid so the compiler won't complain (or maybe with a warning). But the one you used didn't express the behaviour you expected (there is at least on more of those in the code).

And:

void arithmetic (int option, int level)
{
int responce;
int result;

for (int i = 0; i < 5; i=i++)
{
result = generateProblem (option, level);
cin>>responce; // an the meaning of this?
}
}

- petter
wildfrog at 2007-11-11 4:06:08 >
# 6 Re: Need Help finishing school project.
Thats the users' answer for the math problem.
Rick2101 at 2007-11-11 4:07:12 >
# 7 Re: Need Help finishing school project.
But you're not using it for anything. Shouldn't you compare it to what the generateProblem function returned, and based on that make a call to either correctMessage or incorrectMessage?

- petter
wildfrog at 2007-11-11 4:08:05 >
# 8 Re: Need Help finishing school project.
Thats the idea, but I really don't know how to do that :(
Rick2101 at 2007-11-11 4:09:08 >
# 9 Re: Need Help finishing school project.
Something like:

if (response == result)
{
// the answer was correct!
} else
{
// the answer was incorrect
}

- petter
wildfrog at 2007-11-11 4:10:06 >
# 10 Re: Need Help finishing school project.
Edit: err. my mistake.

where exactly do I put that code in? I tried in the for loop and outside, it didn't work either way :(
Rick2101 at 2007-11-11 4:11:07 >
# 11 Re: Need Help finishing school project.
er.. I managed to fix it. I typed in the words backwards :P

Thanks soo much for the help. you've saved my life!
Rick2101 at 2007-11-11 4:12:16 >