Question: Write this program using c++ Write a program that allows young students to practice addition, like flash cards. The program displays a problem using two

Write this program using c++

Write a program that allows young students to practice addition, like flash cards. The program displays a problem using two random numbers in the range of 1 to 12. The user inputs an answer. If the answer is correct, the program should display Thats right!. //declare variables for the two random numbers, // the correct answer and the user answer //seed the random number generator //generate the two numbers in the range of 1 to 12 //and store in the two variables //calculate and assign the correct answer //print the problem //input the user's answer //determine if answer is correct //and print appropriate response The program should operate as follows: (note bold is user input. You will get different problems due to the random number generator) 9 + 10 = 19 That's right 12 + 8 = 18 The answer is 20

Now add a loop so that the program generates three problems and determines the number correct as shown below: (Note that bold represents user input. Also note that your output may have completely different numbers). Note that you will need to add additional variables. Page 2 Welcome to Math Problem 1: 9 + 10 = 19 That's right Problem 2: 12 + 8 = 18 The answer is 20 Problem 3: 5 + 4 = 9 Thats right Number correct is 2 out of 3 Generating Random Numbers The function rand() returns a random number, i. e. y = rand(); //assigns a value in the range 0 to 32767 To limit the range of the random number, use the following formula lower + rand() % (upper lower + 1) For example, to generate numbers between 1=lower and 10=upper: 1 + rand() % (10 1 + 1) or simplify as 1 + rand() % 10 For numbers between 10=lower and 100=upper 10 + rand() % (100 10 + 1) or simplify as 10 + rand() % 91 To get different numbers with each run of the program, you need to seed the random number generator using the srand function. You essentially give the random number generator a starting value. A good way to get different numbers every time is to use the built-in time function as the seed value in srand, as follows: Requires #include srand((time(0))); // NOTE: you only need to do this once at beginning of program

The second part of this problem

using the first part to solve this problem

Write a program that can be used as a math for elementary school students. Display a menu to choose addition, subtraction, multiplication, or division. Generate two random numbers in the range of 1 to 12. For the subtraction problem, make sure the answer is positive (the larger number comes first). For the division problem, we only want integer answers. So multiply the two numbers to create the first number. For example, if the numbers generated were 4 and 5, instead of making the problem as: 4 / 5 (which has a decimal answer), multiply the numbers and use that as the first number, so the problem would be 20 / 5 (which has an integer answer). The program should loop as long as the user wants to continue.

Sample Output (note user input is in bold) Welcome to the Math Select an operation (+ - / *) or q to quit: + 9 + 10 = 19 That's right Select an operation (+ - / *) or q to quit: - 12 - 8 = 2 The answer is 4 Select an operation (+ - / *) or q to quit: / 24 / 6 = 4 That's right Select an operation (+ - / *) or q to quit: * 9 * 3 = 27 That's right Select an operation (+ - / *) or q to quit: q Number of problems: 4 Number correct: 3 Your score is 75% Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!