Answered step by step
Verified Expert Solution
Question
1 Approved Answer
File Display Place the following file containing a series of integers, named numbers-1.txt in a folder on your computer. Write a program that reads the
File Display
Place the following file containing a series of integers, named numbers-1.txt in a folder on your computer. Write a program that reads the contents of the file and displays all of the numbers in the file. Save the program to the same folder that contains the numbers-1.txt file.
Be sure to:
Have a main function.
Declare any variables.
Prompt the user for the filename of the file to be opened.
Open the file for reading.
Read the contents.
Close the file.
Include comments.
Exception Handling
You program will handle the following exceptions:
- Your program should handle any FileNotFoundError: exceptions that are raised when the file is opened. This exception will cause the program to display the message This file is not available..
- Your program should handle any other exceptions that are raised when the items that are read from the file are converted to a number.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started