More Parameter Lists Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists when calling a function from main, by having you make changes to an existing program's function calls. It also gives you more practice with the "random number generator". Requirements. Rewrite the addition.cpp program from chapter 8, and name it myAddition.cpp. Modify the program by using the C++ random number generator to generate the two input numbers for each question. Limit the randomly-selected input numbers to between 0 and 10, inclusive. To avoid having identical code appearing in main 5 times, because specific numbers no longer appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the function. NOTE: You need this as the first statement in "main": srand (time (0)); Never put srand(time (0)); in a loop or function (other than main) -- it should be executed only once. Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5 correct/incorrect responses to a user input. Examples. Here's what the output should look like, with user input in blue: 6 + 4 = 10 Correct! 6 + 6 = 12 Correct! 3 + 7 = 11 Very good, but a better answer is 10 5 + 9 = 14 Correct! 10+ 3 = 13 Correct!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

#include <iostream>
using namespace std;

void additionProblem(int topNumber, int bottomNumber)
{
int userAnswer;
cout << "\n\n\n " << topNumber << " + " << bottomNumber << " = ";
cin >> userAnswer;
cin.ignore(1000, 10);

int theAnswer = topNumber + bottomNumber;
if (theAnswer == userAnswer)
cout << " Correct!" << endl;
else
cout << " Very good, but a better answer is " << theAnswer << endl;
} // additionProblem

int main()
{
additionProblem(8, 2);
additionProblem(4, 8);
additionProblem(3, 7);
additionProblem(4, 10);
additionProblem(11, 2);
} // main 

 

The above code needs to be modified according to the image I've attatched.

More Parameter Lists
Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists
when calling a function from main, by having you make changes to an existing program's function
calls. It also gives you more practice with the "random number generator".
Requirements. Rewrite the addition.cpp program from chapter 8, and name it
myAddition.cpp. Modify the program by using the C++ random number generator to generate the
two input numbers for each question. Limit the randomly-selected input numbers to between 0 and
10, inclusive.
To avoid having identical code appearing in main 5 times, because specific numbers no longer
appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the
function.
NOTE: You need this as the first statement in "main": srand (time (0)); Never put
srand(time (0)); in a loop or function (other than main) -- it should be executed only once.
Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5
correct/incorrect responses to a user input.
Examples. Here's what the output should look like, with user input in blue:
6 + 4 = 10
Correct!
6 + 6 = 12
Correct!
3 + 7 = 11
Very good, but a better answer is 10
5 + 9 = 14
Correct!
10+ 3 = 13
Correct!
Transcribed Image Text:More Parameter Lists Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists when calling a function from main, by having you make changes to an existing program's function calls. It also gives you more practice with the "random number generator". Requirements. Rewrite the addition.cpp program from chapter 8, and name it myAddition.cpp. Modify the program by using the C++ random number generator to generate the two input numbers for each question. Limit the randomly-selected input numbers to between 0 and 10, inclusive. To avoid having identical code appearing in main 5 times, because specific numbers no longer appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the function. NOTE: You need this as the first statement in "main": srand (time (0)); Never put srand(time (0)); in a loop or function (other than main) -- it should be executed only once. Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5 correct/incorrect responses to a user input. Examples. Here's what the output should look like, with user input in blue: 6 + 4 = 10 Correct! 6 + 6 = 12 Correct! 3 + 7 = 11 Very good, but a better answer is 10 5 + 9 = 14 Correct! 10+ 3 = 13 Correct!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The program should be according to the requirement. The requirement says, "Modify the program by using the C++ random number generator to generate the
two input numbers for each question." also, there should be a count-controlled loop in the main To avoid having identical code appearing in the main 5 times.

Please refer to the requirements of the program.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education