Question: In C + + General requirements: - No global variables - No multiple return statements in one function - Show how you have tested these

In C++
General requirements:
- No global variables
- No multiple return statements in one function
- Show how you have tested these functions
- You can use cin and cout in this function but please do not print out the results.
It should return the values to the caller through the use of return type and pass-by-reference parameters.
- Please do not use struct, tuple or pair class.
Please use only pass-by-reference parameters and return type to return values to the caller.
- Please do not use arrays. Please use only simple variables to keep track of the information.
Note: this is an exercise to use functions and not arrays.
Question #1:
Write a function named "readOnePIN" that reads in from the user a pin (integer) and ask the user re-enters the same pin to verify.
It will return the indicator of true or false (match or not matched) and the number of tries the user has attempted.
The user can enter the wrong pin up to only 3 times.
Note: the function must return two separate values to the caller using return types and pass-by-reference parameters.
struct or tuple or pair is not allowed.
Printing is not allowed in the function. It can be done in the testing function or main.
Examples of the output of different program runs:
Please enter the pin: 1234
Please re-enter the pin: 1234
Matched: true
Number of tries: 1
Please enter the pin: 1234
Please re-enter the pin: 1111
Unmatched.
Please re-enter the pin: 2222
Unmatched.
Please re-enter the pin: 1234
Match: true
Number of tries: 3
Please enter the pin: 1234
Please re-enter the pin: 1111
Unmatched.
Please re-enter the pin: 2222
Unmatched.
Please re-enter the pin: 3333
Unmatched.
Match: false
Number of tries: 3
Question #2:
Write a function named "countScores" that will accept a count as the total number of scores to be read in by the function.
After reading the list of scores (integer), it will return the following statistical data for those scores:
- total scores minus the largest and the smallest
- boolean flag indicating whether all scores are passing (meaning greater or equal 70)
Note: the function must return two separate values to the caller using return types and pass-by-reference parameters.
struct or tuple or pair is not allowed.
Printing is not allowed in the function. It can be done in the testing function or main.
Examples of output of different program runs:
If it is passing 5 to the function
Please enter the scores: 1020304050
Total scores: 90
Passing: false
If it is passing 4 to the function
Please enter the scores: 40506070
Total scores: 110
Passing: false
If it is passing 3 to the function
Please enter the scores: 708090
Total scores: 80
Passing: true

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!