The function is named "promptLoyola," and it has the following prototype. // This function will prompt the user for an integer in a particular range //***** YOU MUST IMPLEMENT THIS FUNCTION ***** int promptLoyola ( string, 7/ Tell the user what sort of number is needed, or how it will be used int, int, int, int // The lowest value to allow // The highest value to allow // How many tries the user gets // The default value if the user fails on every try he makes ); You must implement the function along the following steps: 1. The function has five parameters, but none have names in the prototype. To use them you must give each parameter a name that you will use in the body of the program. 2. Declare an int variable to hold the user's response 3. Type out the message in the first parameter ("Tell the user..") 4. Tell the user that the input must be in the range specified by the second and third parameters ("lowest value.." and "highest value.") 5. Get an int value from the user and put it into the variable (yes, go ahead and use cin) 6. If the user's input is in range, return the variable 7. Otherwise count down the number of tries remaining as given in the fourth parameter ("How many tries..") 8. If the user exceed the tries without entering a number in range, return the default value that is in the fifth parameter ("The default value if..")

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C++ Language

The C++ File To Be Revised; The file centered around in this asisgnment

#include <iostream>

using namespace std;

const string PROGRAM_NAME = "test-prompt-loyola";

const int LOW_RANDOM_VALUE = 20, HIGH_RANDOM_VALUE = 25;

// This function will prompt the user for an integer in a particular range

//***** YOU MUST IMPLEMENT THIS FUNCTION *****

int promptLoyola (

string, // Tell the user what sort of number is needed, or how it will be used

int, // The lowest value to allow

int, // The highest value to allow

int, // How many tries the user gets

int // The default value if the user fails on every try he makes

);

int main () {

cout << "Welcome to " << PROGRAM_NAME << endl;

int gotRandom = LOW_RANDOM_VALUE + (rand () % (1 + HIGH_RANDOM_VALUE - LOW_RANDOM_VALUE));

cout << "Test A:\n";

int userGuess = promptLoyola ("Guess the random number!", LOW_RANDOM_VALUE,

HIGH_RANDOM_VALUE, 4, -1);

if (userGuess == -1) { cout << "You didn't want to guess a number?" << endl; }

else {

if (userGuess == gotRandom) {

cout << "You guessed the right number!\n";

} else {

cout << "Sorry, the number was " << gotRandom << endl;

}

}

cout << "Test B:\n";

int userPrefTemp = promptLoyola ("What is your most comfortable temperature? ",

20, 120, 3, -1);

if (userPrefTemp == -1) {

cout << "No answer I guess\n";

} else if (userPrefTemp < 67) {

cout << "Sorry, but " << userPrefTemp << " is too cold for me!\n";

} else if (userPrefTemp > 85) {

cout << "I don't like it that hot!\n";

} else {

cout << "I could go with that...\n";

}

cout << "Test C:\n";

userGuess = promptLoyola ("Guess another number", 1, 1, 1, -1);

if (userGuess == 1) { cout << "Great!\n"; }

else { cout << "no guess...\n"; }

cout << "Test D:\n";

userGuess = promptLoyola ("Zero tries?", 10, 20, 0, 5);

if (userGuess == 5) { cout << "No input\n"; }

else { cout << "Got input " << userGuess << endl; }

cout << "Thank you for using " << PROGRAM_NAME << endl;

return 0;

}

________

This file does not compile successfully; it will give an error like "Undefined symbols..." It gives this error because there is a function that is called by the program, but there is no implementation for the function in the program. The function is named "promptLoyola."

YOUR ASSIGNMENT IS TO WRITE THE FUNCTION AND MAKE IT WORK.

You will see that test-prompt-loyola.cpp already has a main function. It has four tests (A, B, C, D) in which it runs promptLoyola in various ways. You do not need to make any changes to the main function.

 

 

 

The function is named "promptLoyola," and it has the following prototype.
// This function will prompt the user for an integer in a particular range
//***** YOU MUST IMPLEMENT THIS FUNCTION *****
int promptLoyola (
string, // Tell the user what sort of number is needed, or how it will be used
int,
int,
int,
int
// The lowest value to allow
// The highest value to allow
// How many tries the user gets
// The default value if the user fails on every try he makes
);
You must implement the function along the following steps:
1. The function has five parameters, but none have names in the prototype. To use them you must give each parameter a
name that you will use in the body of the program.
2. Declare an int variable to hold the user's response
3. Type out the message in the first parameter ("Tell the user...")
4. Tell the user that the input must be in the range specified by the second and third parameters ("lowest value." and
"highest value.")
5. Get an int value from the user and put it into the variable (yes, go ahead and use cin)
6. If the user's input is in range, return the variable
7. Otherwise count down the number of tries remaining as given in the fourth parameter ("How many tries.")
8. If the user exceed the tries without entering a number in range, return the default value that is in the fifth parameter
("The default value if..")
Transcribed Image Text:The function is named "promptLoyola," and it has the following prototype. // This function will prompt the user for an integer in a particular range //***** YOU MUST IMPLEMENT THIS FUNCTION ***** int promptLoyola ( string, // Tell the user what sort of number is needed, or how it will be used int, int, int, int // The lowest value to allow // The highest value to allow // How many tries the user gets // The default value if the user fails on every try he makes ); You must implement the function along the following steps: 1. The function has five parameters, but none have names in the prototype. To use them you must give each parameter a name that you will use in the body of the program. 2. Declare an int variable to hold the user's response 3. Type out the message in the first parameter ("Tell the user...") 4. Tell the user that the input must be in the range specified by the second and third parameters ("lowest value." and "highest value.") 5. Get an int value from the user and put it into the variable (yes, go ahead and use cin) 6. If the user's input is in range, return the variable 7. Otherwise count down the number of tries remaining as given in the fourth parameter ("How many tries.") 8. If the user exceed the tries without entering a number in range, return the default value that is in the fifth parameter ("The default value if..")
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY