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.