In this lab, you will modify your solution for Lab 4 to make functions to calculate the average and standard deviation of three doubles.
Since this is new syntax, the following code (also in the link lab5_example.cpp) shows how to make a function for calculating the average. You will need to add the function for calculating the standard deviation for the assignment:
// A example program to create our own math functions
// This program will calculate the average and standard deviation of 3 doubles
#include <iostream>
#include <cmath> // For sqrt and pow functions
using namespace std;
// Function: average
// Input: 3 doubles
// Output: Double
// Purpose: Compute the average of three doubles
double average(double, double, double);
// Function: stdev
// Input: 3 doubles
// Output: Double
// Purpose: Compute the standard deviation of three doubles
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Add the prototype for standard deviation here
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int main()
{
double d1, d2, d3;
char again;
do
{
cout << "Enter 3 doubles: ";
cin >> d1 >> d2 >> d3;
cout << "The average is " << average(d1, d2, d3) << endl;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Add the cout for standard deviation here
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cout << "\nDo you wish to enter another set of numbers? (Y|n) ";
cin >> again;
} while(again != 'N' && again != 'n');
cout << "Goodbye\n";
return 0;
}
double average(double num1, double num2, double num3)
{
double avg;
avg = (num1 + num2 + num3) / 3;
return avg;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Add the body for standard deviation here
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name your source code lab5.cpp. Email me the completed source code.