Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab you will practice using basic file input, and using a single dimension array. Be sure to read this lab thoroughly, especially the

image text in transcribed
In this lab you will practice using basic file input, and using a single dimension array. Be sure to read this lab thoroughly, especially the Hand-in Procedure Lab Write a complete program that: 1. Prompts the user for a filename and reads the filename into a string. 2. Opens the file into an ifstream variable and verifies that it opened. If the file does not open the program should output an error and continue from (1). a. The file contains a single column of numbers to be read into an array. The file contains at max 100 values (This means for this lab you are allowed to use an array with a static size of 100 ). 3. Reads all of the numbers from the file opened in (2) into an array. The file should be read in using a while loop that terminates when the end of the file is hit. If invalid input is read in while reading in from the file you should clear/ignore/skip the failed input and continue on to the next input. You should keep track of how many valid numbers you read in as you are reading in numbers from the file. 4. Once all the values are in an array 3 statistics should be found on the numbers contained in the array: a. The minimum b. The maximum c. The sum d. The average Note: You can find (4a), (4b), and (4c) in a loop. After the loop calculate (4d) using (4c) and the count from (3). 5. Prints the amount of elements read into the array from the file. 6. Prints the array starting from element 0 to element arraySize - 1 (forwards). 7. Prints the array starting from element arraySize - 1 to element 0 (backwards). 8. Prints the 4 statistics found in (4). Your program should be able to attempt to open any file name the user enters and should not statically open a file name. You must read your data from the input files into single dimensional arrays, failing to do so will result in you receiving a 0 for this lab. You are not required to use functions in this lab but they are highly encouraged. Output values should be fixed with 2 digits of precision. See the example output for examples and formatting

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions