Recall that the mean T and the standard deviation ơ, are defined as N と;-ア)? ri Or i=1 i=1 and that the median î is defined as the value for which half of the scores are above it and half of the scores are below it. To compute the median, you first need to sort the array. If N is odd, then r is the element r; in the middle of the sorted array; if N is even, then F is the average of the two elements r; and ri+1 in the middle of the sorted array (if you find this confusing, just check Wikipedia, or come to office hours). Your program should be called qualityControl.cpp. You should copy-paste the following code and leave it untouched: #include #include using namespace std; float mean(float*, int); float stdev(float*, int); float median (float*, int); void top2scores (float*, int, float&, float&); void sort(float*, int); int main(void) { // Array for storing the test results cout << "How many test objects do you have? " int n; cin >> n; float* res = new float [n] ; // dynamically allocated memory for res[] // Read in the test results cout << "Enter the " くく n <く " test results: for (int i=0; i> res[i] ; // Print out cout << "Summary test scores: << endl ; %3D " << mean(res, n) << endl ; << stdev(res, n) << endl ; " < median(res, n) << endl ; cout << " mean cout << " stdev cout << median = float bestScore, secondBestScore; top2scores (res, n, bestScore, secondBestScore); cout << " top-2 = " << bestScore <« " " « secondBestScore « endl; return 0; Sample output is: How many test objects do you have? 6 Enter the 6 test results: 43 66 57 29 32 39 Summary test scores: = 44.3333 mean stdev 14.473 median = 41 top-2 = 66 57 Your task is to write the 5 functions needed to complete the program, namely: mean (), stdev(), median(), top2scores (), and sort (). Hints: 1. For sort (), use the provided bubbleSort() function (we will also cover this file in lecture). 2. The mean () function should be straightforward. 3. When writing the stdev() function, you can save yourself work by calling mean() from within stdev () to compute the mean. I know we haven't called functions from within functions, but that is totally acceptable in programming – and it saves you work. 4. To implement median() you will need to be able to determine if a number is even or odd. You can do this the hard way, or the easy way. The easy way makes use of the modulo operator, % (think about it). 5. You will also want to call sort() from within median(). 6. You should think about how to make use of sort () when writing the top2scores() function as well!

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
Recall that the mean T and the standard deviation ơ, are defined as
N
と;-ア)?
ri
Or
i=1
i=1
and that the median î is defined as the value for which half of the scores are above it and half
of the scores are below it. To compute the median, you first need to sort the array. If N is odd,
then r is the element r; in the middle of the sorted array; if N is even, then F is the average of the
two elements r; and ri+1 in the middle of the sorted array (if you find this confusing, just check
Wikipedia, or come to office hours).
Your program should be called qualityControl.cpp. You should copy-paste the following code
and leave it untouched:
#include <iostream>
#include <cmath>
using namespace std;
float mean(float*, int);
float stdev(float*, int);
float median (float*, int);
void top2scores (float*, int, float&, float&);
void sort(float*, int);
int main(void) {
// Array for storing the test results
cout << "How many test objects do you have? "
int n;
cin >> n;
float* res
= new float [n] ;
// dynamically allocated memory for res[]
// Read in the test results
cout << "Enter the "
くく n <く "
test results:
for (int i=0; i<n; i++)
cin >> res[i] ;
// Print out
Transcribed Image Text:Recall that the mean T and the standard deviation ơ, are defined as N と;-ア)? ri Or i=1 i=1 and that the median î is defined as the value for which half of the scores are above it and half of the scores are below it. To compute the median, you first need to sort the array. If N is odd, then r is the element r; in the middle of the sorted array; if N is even, then F is the average of the two elements r; and ri+1 in the middle of the sorted array (if you find this confusing, just check Wikipedia, or come to office hours). Your program should be called qualityControl.cpp. You should copy-paste the following code and leave it untouched: #include <iostream> #include <cmath> using namespace std; float mean(float*, int); float stdev(float*, int); float median (float*, int); void top2scores (float*, int, float&, float&); void sort(float*, int); int main(void) { // Array for storing the test results cout << "How many test objects do you have? " int n; cin >> n; float* res = new float [n] ; // dynamically allocated memory for res[] // Read in the test results cout << "Enter the " くく n <く " test results: for (int i=0; i<n; i++) cin >> res[i] ; // Print out
cout << "Summary test scores:
<< endl ;
%3D
" << mean(res, n) << endl ;
<< stdev(res, n) << endl ;
" < median(res, n) << endl ;
cout << "
mean
cout << "
stdev
cout <<
median =
float bestScore, secondBestScore;
top2scores (res, n, bestScore, secondBestScore);
cout << " top-2 = " << bestScore <« " " « secondBestScore « endl;
return 0;
Sample output is:
How many test objects do you have? 6
Enter the 6 test results: 43 66 57 29 32 39
Summary test scores:
= 44.3333
mean
stdev
14.473
median
= 41
top-2
= 66 57
Your task is to write the 5 functions needed to complete the program, namely:
mean (), stdev(), median(), top2scores (), and sort ().
Hints:
1. For sort (), use the provided bubbleSort() function (we will also cover this file in lecture).
2. The mean () function should be straightforward.
3. When writing the stdev() function, you can save yourself work by calling mean() from within
stdev () to compute the mean. I know we haven't called functions from within functions, but that
is totally acceptable in programming – and it saves you work.
4. To implement median() you will need to be able to determine if a number is even or odd.
You can do this the hard way, or the easy way. The easy way makes use of the modulo operator, %
(think about it).
5. You will also want to call sort() from within median().
6. You should think about how to make use of sort () when writing the top2scores() function as
well!
Transcribed Image Text:cout << "Summary test scores: << endl ; %3D " << mean(res, n) << endl ; << stdev(res, n) << endl ; " < median(res, n) << endl ; cout << " mean cout << " stdev cout << median = float bestScore, secondBestScore; top2scores (res, n, bestScore, secondBestScore); cout << " top-2 = " << bestScore <« " " « secondBestScore « endl; return 0; Sample output is: How many test objects do you have? 6 Enter the 6 test results: 43 66 57 29 32 39 Summary test scores: = 44.3333 mean stdev 14.473 median = 41 top-2 = 66 57 Your task is to write the 5 functions needed to complete the program, namely: mean (), stdev(), median(), top2scores (), and sort (). Hints: 1. For sort (), use the provided bubbleSort() function (we will also cover this file in lecture). 2. The mean () function should be straightforward. 3. When writing the stdev() function, you can save yourself work by calling mean() from within stdev () to compute the mean. I know we haven't called functions from within functions, but that is totally acceptable in programming – and it saves you work. 4. To implement median() you will need to be able to determine if a number is even or odd. You can do this the hard way, or the easy way. The easy way makes use of the modulo operator, % (think about it). 5. You will also want to call sort() from within median(). 6. You should think about how to make use of sort () when writing the top2scores() function as well!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
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