Question
Asked by:
nitrofrost
nitrofrost
Rating : No Rating
Questions Asked: 1
Tutorials Posted: 0
 

$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.

 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
rainman
rainman
Rating (40): A+
Questions Asked: 2
Tutorials Posted: 174, earned $906.64
 

$6.00 C++ Multiplication Program. Does Everything Asked + Bonus Points. Compiled Tested Commented Works

  • This tutorial was purchased 1 time and rated A+ by students like you.
  • Posted on Mar 04, 2009 at 9:52:34PM
A:
Preview: ... What is " << first << " times " << second << "? ";<br> cin >> answer;<br><br> //if -1 is inputted break out of the loop<br> if (answer == -1)<br> break;<br><br> if (answer == multiply(first, second))<br> {<br> cout << "Very good!" << endl;<br> right++;<br> }<br> else<br> {<br> //loop u ...

The full tutorial is about 554 words long .
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty