Question: Write a program to read and total all numbers in a file Prompt the user for a file name Using exception handling: Output a message,
Write a program to read and total all numbers in a file
Prompt the user for a file name
Using exception handling:
Output a message, Could not open file exiting, if the file could not be openedread and exit the program
Output a message, Invalid number: plus the bad line if the value on the line is not a floating point number
Print the grand total at the end of the program
numstxt contains:
apple
banana
numtxt contains:
bad
Sample Run #bold underlined text is what the user types:
File? numstxt
Invalid number: apple
Invalid number: banana
Grand total:
Note: This is an introductore level class and this problem is meant to completed through a mixture of inputsoutputs and exceptions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
