Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that reads up to 50 measurements from a file into an array, determines the minimum measurement, the maximum measurement, and the

Write a C++ program that reads up to 50 measurements from a file into an array, determines the minimum measurement, the maximum measurement, and the trimmed mean (the mean of all values except the minimum and maximum) then outputs to the screen a formatted report using output manipulation functions.

1) The input file is named measures.in :

The first line of the file is a line of text describing the data. You must use this as the title of the report.

All lines after the first contain one real number, the measurement. You must read these into an array until you have read 50 of them or you reach the end of the file, whichever comes first.

2) You must define and use global constants for: the maximum number of measures to be read, the number of columns in the output, and the width of each column.

3) You must use and define the following six functions; you may define more functions if you find it useful to do so.

(a) getTitle: Parameters: an ifstream connected to the input file Return: a string, the report title This function reads the report title from the file (b) getMeasures Parameters: an ifstream connected to the input file, the array of doubles to store the measures, an int to store the number of measures read Return: none This function reads the measures from the file into the array and count the number of measures read. (c) determineMax (NOTE: this behaves differently than findMin) Parameters: the array of measures, the number of measures Return: a double, the value of the maximum This function determines the value of the maximum. (d) findMin (NOTE: this behaves differently than determineMax) Parameters: the array of measures, the number of measures Return: an int, the position of the minimum value in the array This function finds the position of the minimum value in the array, if the minimum appears more than once the first instance of the value is returned. (e) calcTrimmedMean Parameters: the array of measures, the number of measures Return: a double, the trimmed mean This function calculates the trimmed mean. The trimmed mean is the mean of all the measures except the minimum and the maximum. This function calls determineMax and findMin. (f) printMeasures Parameters: the array of measures, the number of measures

Return: none

This function prints the measures in 10 columns of width 8.

Here is the content of the file:

Blaster Size (Galactic Standard Units) - Sampled from Corscanti Vendors

17.9 24.6 10.3 19.2 6.3 20.6 15.2 22.2 20.2 23.6 7 26.5 26.9 5.7 10.2 10.7 5.4 23.6 17.1 17.8

5.1

24.6 12.3 13.1 23 8.5 12.1 15.7 16.2 22.6 18.6

23.3 18.8 18.5 6.9 16.7 18.4

Here is how the final output must look like:

image text in transcribed

Note: So far in this semester, I have learnt switch and if statments. Also do-while loops. Plus strings, functions and now arrays. I guess you gotta use most of these to write the code.

Please do not use struct statements while writing the code. I will take that next week.

Blaster Size Galactic Standard Units Sampled from Corscanti Vendors 17.90 24.60 10.30 19.20 6.30 20.60 15.20 22.20 20.20 23.60 7.00 26.50 26.90 5.70 10.20 10.70 5.40 23.60 17.10 17.80 5.10 24.60 12.30 13.10 23.00 8.50 12.10 15.70 16.20 22.60 18.60 23.30 18.80 18.50 6.90 16.70 18.40 The minimum measurement is 5.10 The maximum measurement is 26.90 16.38 The trimmed mean is

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

13. You always should try to make a good first impression.

Answered: 1 week ago