Question: Lab 1 Direction: Submit the typed source code. Class Statistics For this lab, you will be evaluating the class from assignment 1. To recap, a

Lab 1

Direction: Submit the typed source code.

Class Statistics For this lab, you will be evaluating the class from assignment 1. To recap,

a students record consists of the following assignments: Assignments Homework 1 Homework 2 Homework 3 Homework 4 Homework 5 Homework 6 Homework 7 Homework 8 Homework 9 Homework 10 Quiz 1 Quiz 2 Quiz 3 Quiz 4 Quiz 5 Midterm Final Indices 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 You will have to complete the following code. I. blank

Name: Sort() Parameter(s): float[] : data int : size Return: nothing Description: sorts the elements of data whose size is size in ascending order.

II. blank

Name: Maximum() Parameter(s): float[] : data int : size Return: float Description: returns the largest element of data whose size is size.

III. blank

Name: Minimum() Parameter(s): float[] : data int : size Return: float Description: returns the smallest element of data whose size is size.

IV. blank

Name: Range() Parameter(s): float[] : data int : size Return: float Description: returns the distance between the smallest and largest elements of data whose

size is size.

V. blank

Name: Median() Parameter(s): float[] : data int : size Return: float Description: returns the median of elements of data whose size is size. If an ordered list has an odd number of elements, the median is the middle number; otherwise, it is the average of the two middle numbers.

VI. blank

Name: Mean() Parameter(s): float[] : data int : size Return: float Description: returns the average of elements of data whose size is size.

VII. blank

Name: StandardDeviation() Parameter(s): float[] : data int : size Return: float Description: returns the standard deviation of elements of data whose size is size.

VIII. blank

Name: OutlinerCount() Parameter(s): float[] : data int : size Return: float Description: returns the number of elements of data whose size is size that are outliners. An outliner is a values whose z-score is either less than -2 or greater than 2.

Type

Task A B A B C A B C D

Problem Set

I, II, V, VI

III, IV, VII, VIII

I, VI

II, III, IV, V

VII, VIII

I, III

II, VII

IV, VIII

V, VI

--------------

This is what I have with my current code.

I'm having trouble finishing the code. This is what I have so far. The Repository and the main shouldn't be altered.

StandardDeviation.h:

#ifndef STANDARDDEVIATION_H #define STANDARDDEVIATION_H #include "Archive.h" #include  namespace labI { float StandardDeviation(float data[], int size) { return -1; } } #endif 

main.cpp:

#include "Repository.h" using namespace labI; void TestUnits() { bool (*func[8])() = { &SortTest, &MinimumTest, &MaximumTest, &RangeTest, &MedianTest, &MeanTest, &StandardDeviationTest, &OutlinerTest }; string tests[8] = { "Sort ", "Minimum ", "Maximum ","Range ", "Median ", "Mean ", "Standard Deviation ", "Outliner Count " }; for (int i = 0; i < 8; i += 1) { cout << tests[i] << ((func[i]()) ? ("Test has passed.") : ("Test has failed.")) << " "; } } int main() { float data[30][17]; if (RetrieveData(data, "data.dat")) { TestUnits(); PrintReport(data, 30, "records.dat"); } else { cout << "Could not retrieve data. "; } return 0; } 

Repository.h:

#ifndef REPOSITORY_H #define REPOSITORY_H #include "Sort.h" #include "Maximum.h" #include "Minimum.h" #include "Mean.h" #include "Range.h" #include "Median.h" #include "OutlinerCount.h" #include "StandardDeviation.h" #include  #include  #include  #include  #include  using namespace std; namespace labI { bool RetrieveData(float data[][17], string filename) { fstream fin(filename.c_str(), fstream::in); if (fin.is_open()) { for (int i = 0; i < 30; i += 1) { for (int j = 0; j < 17; j += 1) { fin >> data[i][j]; } } fin.close(); return true; } fin.close(); return false; } bool SortTest() { float data[17] = { 17, 58, 48, 2, 42, 21, 29, 51, 39, 57, 37, 48, 24, 37, 39, 42, 34 }; int size = 17; Sort(data, size); for (int i = 0; i < (size - 1); i += 1) { if (data[i] > data[i + 1]) { return false; } } return true; } bool MaximumTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (Maximum(data, size) == 98); } bool MinimumTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (Minimum(data, size) == 10); } bool RangeTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (Range(data, size) == 88); } bool MedianTest() { float data1[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size1 = 17; float data2[16] = { 51, 79, 82, 41, 58, 61, 10, 95, 78, 98, 11, 84, 97, 74, 79, 83 }; int size2 = 16; return ((Median(data1, size1) == 78) && (Median(data2, size2) == 78.5)); } bool MeanTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (abs(Mean(data, size) - 68.1176) < 0.01); } bool StandardDeviationTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (abs(StandardDeviation(data, size) - 25.8773) < 0.01); } bool OutlinerTest() { float data[17] = { 51, 79, 82, 41, 58, 78, 61, 10, 95, 78, 98, 11, 84, 97, 74, 78, 83 }; int size = 17; return (OutlinerCount(data, size) == 2); } string PrintRecordData(float data[], int size) { stringstream out; out << "Data: ["; for (int i = 0; i < size; i += 1) { out << setw(4) << setfill(' ') << data[i]; } out << "] "; return out.str(); } string PrintRecordStat(float data[], int size) { stringstream out; string labels[7] = { "Mn: "," Mx: "," Rn: "," Md: ", " Av: ", " Sd: ", " Oc: "}; float(*func[7])(float[], int) = { &Minimum, &Maximum, &Range, &Median, &Mean, &StandardDeviation, &OutlinerCount}; out << "Stat: ["; out << setprecision(2) << fixed; for (int i = 0; i < 7; i += 1) { out << labels[i] << setw(6) << setfill(' ') << func[i](data, size); } out << "] "; return out.str(); } void PrintReport(float data[][17], int size, string filename) { ofstream fout(filename.c_str(), fstream::out); if (fout.is_open()) { fout << "ASSIGNMENT ASSESSMENT "; float adata[30]; for (int i = 0; i < 17; i += 1) { for (int j = 0; j < 30; j += 1) { adata[j] = data[j][i]; } if (i >= 0 && i < 10) { fout << "Homework " << setw(2) << setfill('0') << (i + 1) << " "; } else if (i >= 10 && i < 15) { fout << "Quiz " << setw(2) << setfill('0') << (i - 9) << " "; } else if (i == 15) { fout << "Midterm "; } else { fout << "Final "; } fout << PrintRecordData(adata, 30); fout << PrintRecordStat(adata, 30); fout << " "; } fout << "STUDENT ASSESSMENT "; for (int i = 0; i < 30; i += 1) { fout << "Student " << right << setw(2) << setfill('0') << (i + 1) << " "; fout << PrintRecordData(data[i], 17); fout << PrintRecordStat(data[i], 17); fout << " "; } } fout.close(); } } #endif 

Range.h:

#ifndef RANGE_H #define RANGE_H #include "Archive.h" namespace labI { float Range(float data[], int size) { return -1; } } #endif 

Outlinercount.h:

#ifndef OUTLINERCOUNT_H #define OUTLINERCOUNT_H #include "Archive.h" #include  namespace labI { float OutlinerCount(float data[], int size) { return -1; } } #endif 

Minimum.h:

#ifndef MIMIMUM_H #define MINIMUM_H #include "Archive.h" namespace labI { float Minimum(float data[], int size) { return -1; } } #endif 

Median.h:

#ifndef MEDIAN_H #define MEDIAN_H #include "Archive.h" namespace labI { float Median(float data[], int size) { return -1; } } #endif 

Mean.h:

#ifndef MEAN_H #define MEAN_H #include "Archive.h" namespace labI { float Mean(float data[], int size) { return -1; } } #endif 

Maximum.h:

#ifndef MAXIMUM_H #define MAXIMUM_H #include "Archive.h" namespace labI { float Maximum(float data[], int size) { return -1; } } #endif 

Sort.h:

#ifndef SORT_H #define SORT_H #include "Archive.h" namespace labI { void Sort(float data[],int size) { return; } } #endif 

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!