0

Hi i am doing a program that has to add up the percentage for example if i get one question wrong it adds to the percentage and after i answer 20 questions i would get the final mark but i dont get why it doesnt work.

```
void multiplier(int difficulty)// function to multiply values
{
int answer = 0;
int num1 = 0;
int num2 = 0;
int rightanswer = 0;
int total = 0;
srand (time(0));
for (int counter = 0; counter < 20; counter++)
{
if (difficulty == 1)
{
num1 = 1+rand()%9;
num2 = 1+rand()%9;
}
else if (difficulty == 2)
{
num1 = 1+rand()%99;
num2 = 1+rand()%99;
}
rightanswer = num1 * num2;
while(answer != rightanswer)
{
cout << "What is " << num1 << " * " << num2 <<"?"<< endl;
cin >> answer;
cout <<endl;
if (answer == rightanswer)
{
rightresponse();
}
else
{
wrongresponse();
}
cout <<endl;
total += answer;// add the answer to total value
}// end while
}//end for
evaluate(total);
void evaluate(int total)
{
int percent;
percent = total / 20 * 100;
cout << "Percentage is " << percent << "%"<< endl;
if (percent < 75)// if the percentage is less than 75
{
cout << "Please ask instructor for extra help" << endl;
}
else // if greater than 75
{
cout << "Well done! " << endl;
}
}
```

*Edited 7 Years Ago by Nick Evan*: Added code-tags