PROGRAM A: This program should use a main function and another function named makelist as follows:
- In main, generate a random integer that is greater than 5 and less than 13.
- Print this number on its own line.
- Call the makelist function with the random integer as sole argument.
- Inside the makelist function:
- Make an empty list.
- Use a loop to append to the list a number of elements equal to the random integer argument. All new list elements must be random integers ranging from 1 to 100, inclusive. Duplicates are okay.
- Return the list to main.
- Back in main, catch the returned list and sort it.
- Finally, use a for loop to display the sorted list elements, all on one line, separated by single spaces.
SAMPLE OUTPUT
List size will be 7
Here is the sorted list:
8 28 35 41 51 62 72
ANOTHER SAMPLE OUTPUT
List size will be 10
Here is the sorted list:
3 3 9 20 36 43 48 50 81 93
PROGRAM B: Use the text file named scores.txt (supplied). It contains a number of integer test scores, one per line. Your program should use a main function and another function named showscores as follows:
- In main, create an empty list.
- Open the file named scores.txt.
- Use awhile loop that can detect the end of fileto read the scores, and add them to the list.
- Close the file.
- Call the showscores function with the list of scores as sole argument.
- Inside the showscores function:
- Process the list of scores.
- NOTE: your instructor will use a modified version of scores.txt with different scores and a different number of scores. Your code should be capable of handling this.
- Print out the average score accurate to two decimal places.