Question: In lab 1 2 we built a program that calculates the mean and median based on the data from a file. However, what if the

In lab 12 we built a program that calculates the mean and median based on the data from a file. However,
what if the user types in the wrong file name? In this lab the goal is to refactor lab 12 to handle a
FileNotFoundError .
The user should enter the name of the file.
If the file exists, process it similar to lab 12.
If it doesnt exist, inform the user and ask if they would like to enter a different file name
If the file was processed successfully, inform the user of such.
Additionally, keep track of the number of attempts the user tries to enter a file name. Include both successful
and unsuccessful attempts.C:IWINDOWS SYSTEM32/cmd.exe
enter file name: abc
File not found. Try another file name? (yn):y
number of tries so far: 1.
enter file name: xyz
File not found. Try another file name? (yn):y
number of tries so far: 2.
enter file name: fruit.txt
File not found. Try another file name? (yn):y
number of tries so far: 3.
enter file name: unknown
File not found. Try another file name? (yn):n
number of tries so far: 4.
No file found. Exiting program.
(program exited with code: 1)
Press any key to continue ...
In lab 1 2 we built a program that calculates the

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 Programming Questions!