Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Some automated computer-based machines can output a text file containing rows and columns of numeric data values. These data values may, for example, give a

Some automated computer-based machines can output a text file containing rows and columns of numeric data values. These data values may, for example, give a history of the operation and status of the machine while completing a certain job. Many times, technicians need to extract specific columns of numeric data from one of these files and write it to a new file. During that process, they also may want to analyze the extracted data. Building a computer program to do both of those tasks (data extraction and analysis) is the focus of this assignment.

C++ program that does the extraction and analysis described above except that the tasks shall be made somewhat simpler. The program shall read from a file "inputdata.txt" containing a name and exactly five values of floating point numbers per line in the file. The first line of the file shall contain the name of the person (first and last) that gathered the data i.e. Joe Jones. The second line of the file shall be the first row of data.

As the program reads each row of data, it shall do two things: it shall keep a running sum of the values read for that row, and shall also write the average of that row to a file "averages.txt". The program will continue reading from the file until it reaches the end of the file. This will lintel using a "while" loop and the eof() function that is talked about in Chapter 13 of the text book. The person's name is to be read in at one time using "getline" and stored under a single variable name.

Note that the program shall have no interaction with a user except for starting the program using an IDE or the command line. This means that the program shall NOT prompt the user for the entry of any data. When the program is done, it shall print to the screen the name of the person that sent the data i.e Joe Jones and the name of the output file i.e. "averages.txt".

Software Design

The design of the program consists of two function definitions: main, rowAverage.

float rowAverage(float num1, float num2,float num3,float num4,float num5)

Declare five floating point variables to hold the five numbers that are being sent each time from a row in the input file. (Note: These five variables could be declared more appropriately using an array, but we are not covering that data structure until next unit, so do not use it here.) Set up the function to add up all the values sent and save them in a local variable. Then using that variable divide by 5 and save it in another local variable. Return this value back to the "main" function that has called this function. Now it would be much easier to do all this in the "main" but we are setting things up for the topic of the next unit.

Print just the averages the output file (nothing more or nothing less). i.e.

24.63 56.1 48.9 . . .

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

5. What decision-making model would you advocate to this person?

Answered: 1 week ago

Question

6. What data will she need?

Answered: 1 week ago