Question: C++ Program: Write a program that takes its input from a file of numbers of type double, ouputs the largest number found in the file
C++ Program: Write a program that takes its input from a file of numbers of type double, ouputs the largest number found in the file and the average of the numbers in the file to a file. The file contains nothing but numbers of type double seperates by blanks and/or line breaks. You will need to create one or more test files in to test your program. Allow the user to repeat the operation.
Here's what I have so far and I'm stuck:
/* This program takes its input from a file of numbers of type double and outputs: - the largest number found in the file - the average of the numbers in the file to a file The file contains nothing but numbers of type double deperated by line breaks. Contains one or more test files to test the program & allows uer to repeat the operation. */
#include
using namespace std;
//main function int main() { ifstream in_stream; ofstream out_stream; //variable declaration char filename[16]; //filename contains 15 or fewer characters int num; //integers in the file int num_of_int; /umber of integers in the file double largest_int = 0; //holds the largest number double avg_of_int = 0; //holds the integer of all the integers
//get the filename from the user cout > filename;
//verify if the file exists in_stream.open("infile.txt"); if (in_stream.fail()) { cout
//close the files in_stream.close(); out_stream.close(); }

Example output: The largest number in the file is The average of all of the numbers in the file is 12.425 End program Above results are for the test file: 12.0 14.5 17.0 6.2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
