I think I would try to break this into separate functions instead of having one huge main function.
You only need to seed the random function once at the beginning of the program, not every time you go into a set of problems.
At all times the student should know what question in the set he/she is working on out of 10 questions. |
If you have a for loop, you know the number of the current problem and the total number of problems, so you'll have this info to print to the screen.
The user should also know how many attempts he/she has taken per question. If the user answers a problem incorrectly, the user should be notified that the response is incorrect and be given multiple chances to answer the question correctly. With each incorrect answer, the attempt count should increase. |
Looks like the assignment allows you to choose how many guesses the person gets per question. You need to keep a counter of how many attempts are made
for that particular question and for the overall set of questions. I'd probably use a while loop to let them enter an answer until they get it correct or until they run out of attempts, whichever comes first.
The user's grade should be calculated as (correctAnswers / NumberOfAttempts * 100). |
You should be keeping track of the total number of attempts, and then you just need to track the number of correct answers. If there are a fixed number of questions, you can track either the number of wrong or correct and easily be able to calculate the other.
The initial menu should be re-displayed and the user given the opportunity to attempt another set of random problems from the chosen operation. |
I'd probably put the menu display into its own function and validate that they enter a valid option. Then call the appropriate function for the problem set they chose, or exit the program if they want to exit.
There's a section on file input/output here.
http://www.cplusplus.com/doc/tutorial/files/
Someone also linked this pdf on files in another post which might be helpful.
http://www.umich.edu/~eecs381/handouts/filestreams.pdf