Am I on the right track.

Please Help:

Objective: To create a C++ Console application that utilizes looping control structures to create the Fun with Multiplication application.

General Specification:
Fun with Multiplication should begin by prompting the user for how many multiplication problems to solve.

How Many Multiplication Problems: <user enters 5>

For each problem the application should generate two random numbers between 1 and 12 and present them in multiplication form: ie. 6 X 4 = ?. The application should continue to present each problem until the correct answer is entered. The application should acknowledge a correct response with an affirmative statement.
6 X 4 = <user enters 30>
6 X 4 = <user enters 20>
6 X 4 = <user enters 24>
Correct!
12 X 9 = ?
After serving the specified number of multiplication problems the application should congratulate the user on completing the task and display a statistical summary of their session.

Congratulations on Completing your Mission!
Problems: 5 Guesses: 8 Accuracy: 62.5%

Finally, your application should query the user to ‘Go Again?’, If the response is ‘Y’ or ‘y’ the application should loop to the ‘How many problems’ prompt. If the response if ‘N’ or ‘n’ the application should offer a final thanks and end.
Thanks for using Fun with Multiplication!

the above is the problem
Last edited on
tHIS IS WHAT I HAVE SO FAR:

#include <iostream>
#include <iomanip>
#include <ctime>

using namespace std;
int main()
{
int num1, num2, answer, guess;

num1 = rand() % 12 + 1;
num2 = rand() % 12 + 1;
answer = num1*num2;

int count = 0;
char r;
int numQ, x;
double accuracy = (double)numQ / count++ * 100;

cout << "Please enter the desired number of questions: " << endl;
cin >> numQ;
cout << "Generating" << numQ << "questions" << endl;
for (x = 0; x <= numQ; x++)
{
do {
cout << num1 << " x " << num2 << " =";
cin >> guess;
count++;
} while (guess != answer);
cout << "Correct, you got it in " << count << " tries" << endl;
cout << fixed << showpoint; cout << setprecision(1);
cout << "Problems: " << numQ << " " << "Guesses: " << count++ << " " << " Accuracy: " << accuracy << "%" << endl;
}
do {
cout << "Do you want to go again Y/N: " << endl;
cin >> r;
} while (toupper(r == 'Y'));
cout << "Thank you for playing!" << endl;

return 0;
}
Last edited on
when i go to run without debugging all that comes up is press any key,

im so flustered what have i done wrong
> all that comes up is press any key,
then you are not running that program.
you should get Please enter the desired number of questions: at least.

make sure that you've saved your changes, that you are compiling that code (that it is compiling).

> what have i done wrong
A lot of things. Here you have the flow diagram of your code http://s12.postimg.org/lal1yr899/flow_diagram.png
note how the operations are outside the loop, and even with invalid data.

Before coding, try to write the flow diagram or the pseudo-code of what you are trying to accomplish.
Also, you are off by one in the loop. Try to do a desk check (emulate that you are the computer and follow your code line by line).
Topic archived. No new replies allowed.