Question
Asked by:
$1.00 C++ random numbers, inline function
- From Computer-Science: General-CS
- Closed, but you can still post tutorials
- Due on Mar. 07, 2009
- Asked on Mar 04, 2009 at 9:10:25PM
Q:Objective: learn how to:
-- generate random numbers
-- use inline function
-- solve a real problem
Problem:
Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. The program should then output a question using the numbers, such as:
How much is 6 times 7?
where the first number must be less than or equal to the second. The student then types the answer. The program checks the student’s answer. If it is correct, print “Very good!” Otherwise, print “Sorry, you are wrong!” Then ask another multiplication question until the answer is -1.
Requirements:
You must use rand and srand functions to generate two integers each time and must write an inline function to compute the multiplication, though it is simpler without function.
2 Bonus Marks:
Use two integers to count the number of right and wrong answers. After the student has entered –1, print “You did X correct and Y wrong.” Furthermore, if the answer is wrong, print “No. Please try again.” Let the student try the same question repeatedly until the student gets it right. The number of wrong answers should be accumulated even for the same problem.



