Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 17: Functions with Reference Parameters In this lab you will continue to practice writing functions. In addition to writing functions with value parameters (as

Lab 17: Functions with Reference Parameters In this lab you will continue to practice writing functions. In addition to writing functions with value parameters (as you did in the previous lab), you will write functions with reference parameters. You will use reference parameters to pass more than one value back to the calling function. Your Program You will complete a program that calculates a contestant's score based on the scores from five judges. The highest and lowest of the judges' scores are thrown out, and the contestant's score is the average of the remaining three judges' scores. I have already written the main function: contestantScore.cpp. You should not make any modifications to this file. You will modify the code in the contestantScore.h file. I have provided you the function to get user input. You will write two additional functions, as specified in the comments in the file. Note that the prototypes of the functions you write must match the calls to those functions from the main program. You may not use global variables. The tips.cpp file gives you some examples to look at when you are writing the code in your functions. The output from your program should look similar to the following figure. image text in transcribed

#include #include #include

using namespace std;

// // This function gets a double between 0 and 100 from console input // // DO NOT MODIFY THIS FUNCTION // double getDouble0to10(string message) { double num; cout > num; // Check for valid input // We have to be careful when comparing doubles. // If the user enters a number just slightly bigger than 10 // (such as 10.00000000000000001) the computer will // not see that the user input is greater than 10. I can't get the // same thing to happen with the low end of the input, probably because // I am alwyas entering a negative sign before the number. But I use // the floor function just to be safe. We use the floor // and ceil functions to ensure we are comparing whole numbers. while ( !cin || floor(num) 10 ) { // Reset the input stream and remove any remaining // input cin.clear(); cin.ignore(5000, ' '); // Ask for valid input cout > num; } // Return the number input by the user return num; } // end getDouble0to100 function

//////////////////////////////// // Start of your code

// // This function finds the minimum and maximum of a series of 5 numbers // This function should have a void return type. // You must use some reference parameters for this function. // // Write this function //

// // Find the average of 5 numbers excluding the minimum and maximum // If there is more than one number with the minimum or maximum value, // only exclude the number one time. For example, if the numbers are: // 4.5 6.7 2.3 7.8 2.3, the average is calculated using the numbers: // 4.5 6.7 2.3. // // This function must call the above function that finds the minimum and maximum // values in a series of 5 numbers. // // This function does not use reference parameters // // Write this function //

// End of your code //////////////////////////////// (Use this to follow and complete code)

CAUserscreilly Documents Visual Studio 20081Projects\CSCI1370 Fall2011 ContestantScore Debu.. This program calculates the contestant's score based on scores from 5 judges The highest and lowest scores are dropped Score from judge 1 7.3 Score from judge 2: 8.5 Score from judge 3 9.6 Score from judge 4: 3.5 Score from judge 5 w You entered incorrect input Enter a double between and 10: 1999929 You entered incorrect input Enter a double between and 10: -23455 You entered incorrect input Enter a double betweenand 10: 5.9 The contestant s score is: 7.23333 ress any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions