Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program is in C++ . Write a function named averageValueInFile that accepts a file name as a parameter and reads that file, assumed to be

Program is in C++ . Write a function named averageValueInFile that accepts a file name as a parameter and reads that file, assumed to be full of real numbers, and returns the average (mean) of the numbers in that file. The parameter, filename, gives the name of a file that contains a list of real numbers, one per line. You may assume that the file exists and follows the proper format. For example, if a file named input.txt contains the following numbers

1.5 2.75 9.0 -3.25 0.0 6.5 

Then the call of averageValueInFile("input.txt"); should return 2.75.

You may assume that the input file exists and is in the proper format. If the file does not contain any input values, return 0.0.

Constraints: Your solution should read the file only once, not make multiple passes over the file data.

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

=+How will this product help them?

Answered: 1 week ago

Question

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

Answered: 1 week ago