Question: The solution should be in python. This Programming Challenge will require you to write a simple program that writes and reads random numbers from a

The solution should be in python.

This Programming Challenge will require you to write a simple program that writes and reads random numbers from a text file and displays the total and average of those numbers.

Instructions

To begin this challenge, you will create a menu structure with the following selections:

1.Add New Number Set

2. Display Present Number Set

3. Display Number Set Report

4. Exit Program

Add New Number Set - For this selection, you will first ask the user how many numbers they would like to add to the set. You will then use the random number generator method to create that many numbers. The numbers must be between 1 and 500. Those numbers should be written to a text file called "number_set.txt". Note that this operation should replace any previous number set written to the file.

Display Present Number Set - For this selection, you will read all of the numbers from the numbers_set.txt file and display those numbers to the screen. If the text file is empty, which will be the case the first time the program is ran, the program should display a message stating that there are no numbers present in the set.

Display Number Set Report - For this selection, you will display a report for the number set. That report should contain the Sum of the numbers, the Average of the numbers, the Highest number and the Lowest number in the set. Note that when obtaining the average, you will need to divide by the total number of values in the text file. However, if there are no values in the text file, this my throw an exception. So you should validate that the file contains values before displaying the report.

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!