Question: Write a complete program that: 1. Creates a variable to keep track of a running total. 2. Prompts the user for a filename and reads

 Write a complete program that: 1. Creates a variable to keep

Write a complete program that: 1. Creates a variable to keep track of a running total. 2. Prompts the user for a filename and reads the filename into a string. 3. Opens the file, and verifies that it opened. If the file does not open the program should output an error message and start from (2) again. a. The data file contains sets of two numbers per line, space delimited, and may contain letters. 4. Reads in two numbers from the data file. a. If either number read in from the line causes input failure (i.e. a character in the line), your program should clear the fail bit, discard the row of failed input, and continue from (3) on the next row. 5. Adds the 2 numbers from (4) together. 6. Adds the result from (5) to the running total from (1). 7. Writes the result from (5) to the screen (see example output for formatting). 8. Continues from (3) until the end of file is hit. 9. Once the end of the file is hit, output the running total. All lines of data should be read and the program should not exit until the end of file is hit. Any line of data that contains a letter should be discarded (clear the fail bit and ignore any characters remaining on the line). See the example output for examples and formatting

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!