Work with files
Ask for a file name. The file should exist in the same folder asthe program. If using input() to receive the file name do not giveit a path, just give it a name like “number1.txt” or somethingsimilar (without the quotes when you enter the name). Then ask fortest scores (0-100) until the user enters a specific value, in thiscase, -1. Write each value to the file as it has been entered. Makesure to close the file once the user has finished entering in thedata.
You can use input() orFileUtils.selectOpenFile/FileUtils.selectSaveFile for receiving thefile name from the user in either part. The FileUtils functionswill be discussed in class Wednesday. The file can be downloadedfrom the examples folder in Blackboard. There may be LOTS ofdifferent FileUtils files available in the wild, make sure you getmy file from Blackboard. Keep in mind that entering no actual datais legal (after entering a file name you enter -1 right away) andshould be considered in part 1 and part 2.
Part 2 (separate program)
Ask for a file name. Don’t let the program crash if you enterthe name of a file that does not exist. Detecting this will also bediscussed on Wednesday. If the file doesn’t exist gracefullydisplay an error message stating the file doesn’t exist and quitthe program.
It the file does exist read all the values in the file. You willonly need to read the file once, or more to the point, only readthe file once. After the program has finished reading all the data,display the following information to the screen:
• The minimum value
• The maximum value
• The average – display with 3 places after the decimal point
• The total number of values
• The total number of values greater than or equal to 70
• The total number of values less than 70
• The value closest to 70 (can be 70, less than 70 or greater than70). abs will be useful
for this value.
• The value closest to 70 WITHOUT going over 70 (can be 70, WILLNOT be greater than70)
If no data exists in the file, write out a simple messageindicating that there was no data in the file and nothing else.
Complete comment section that includes your name, id number,program number and a brief description of the program.
Answer to Objectives Work with files Assignment Part 1 Ask for a file name. The file should exist in the same folder as the progra…