Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you must use an array (declared in main.cpp ), to store all the integers from the file, prior to processing you must modify your existing

image text in transcribed

you must use an array (declared in main.cpp), to store all the integers from the file, prior to processing

you must modify your existing readfile and writefile functions, to conform to the following specifications:

void readfile(int arr[], int& count);

//Read unknown count of integers from input and store in array arr[]

// Pre-Condition: Filename is stored in global constant. array and count have been declared in main.

//Post-Condition: infile (global constant in subs.h) has been opened (cerr message and exit program, if fails) for reading; an unknown number of integers has been read from the file and stored in the array; count has been set to equal the number of integers read. Input file has been closed.

//Libraries used:

void writefile(double avg, int count);

// Write average and count values to output file, with labels (see sample output)

// OUTPUT FORMAT: labels should be in column 1, width 20, right aligned; values should be in column 2, witdth 10, right aligned, fixed decimal, with 2 digits of precision (see examples)

//Pre-Condition: average and count have already been determined; output file does not exist or will be overwritten.

//Post-Condition: average and count values has been written to output file and file closed. If unable to open output file for writing, send error message to cerr, and exit program.

//Libraries used: ....

create a function to compute the averages (remove/replaces functionality for min/max)

double average(const int arr[], int count);

// Computes the average for numbers in array, representing one input file

//Pre-Condition: arr and count have been stored

//Post-Condition: average is returned

?

define Sues H tinclude using namespace std std: const string infile-nie.d const 5tring outfilc-"outiis dat" const int MaxCount 1001; void readfile (int arrl,ints ount) double average (const in: arr], int count) vaid writerile (avg, int. c)

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions