CS 010 - Introduction to Computer Science I
Assignment 8: Arrays

(Deadline extended to Wednesday) DUE: Tuesday, June 1 before 11:00pm


Collaboration Policy

Collaboration is strictly FORBIDDEN. Programs must represent YOUR OWN original work. Sharing code or team-coding are not allowed for this assignment. Copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is not allowed. Cooperation to the extent of helping to debug, or discussing the general approach to solving the problem is encouraged, but should never involve communicating code or even pseudo-code or explicit algorithms. Your code must be unique -- if it is not, we will find out, and will treat it as a case of flagrant academic dishonesty.


You must turn in a C++ source file (and only a C++ source file). The name for your source file should be as8.cpp.

Turn in online to the appropriate folder for your lab section (e.g., as8_sec20 for students enrolled in lab section 20). If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).

Remember to include the header as it is in the template provided on the class website.


Problem Definition:

Write a program that gives the user a menu of 8 options. The options are:

  1. Read in 20 scores (integers) from the user.
  2. Read in 20 scores from a file, scores.txt.
  3. Print the 20 scores.
  4. Print the maximum score.
  5. Print the minimum score.
  6. Print the mean (average) of the 20 scores.
  7. Print a score and how far it is from the mean.
  8. Exit the program.

Sample Run

Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
1

Enter score #1: 80
Enter score #2: 90
Enter score #3: 100
Enter score #4: 6
Enter score #5: 68
Enter score #6: 85
Enter score #7: 50
Enter score #8: 79
Enter score #9: 98
Enter score #10: 99
Enter score #11: 102
Enter score #12: 56
Enter score #13: 85
Enter score #14: 95
Enter score #15: 77
Enter score #16: 60
Enter score #17: 84
Enter score #18: 58
Enter score #19: 92
Enter score #20: 73

Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
4

Maximum score: 102


Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
5

Minimum score: 6

Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
6   

Mean: 76.85


Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
7

Enter entry # of score you want:10


Entry #10: 99 is 22.15 over the mean.

Enter your choice:

1. Read in 20 scores from user.
2. Read in 20 scores from the file, scores.txt.
3. Print all scores.
4. Print the maximum score.
5. Print the minimum score.
6. Print the mean.
7. Print one score (give its entry number)
8. Quit program.
8

Rubric: (10 pts total + 1 bonus pts)

For 1 pt BONUS include 1 more option. This option should print the median score. For this you woule need to sort the array. The median is the middle of a distribution. After sorting the array, the median would be the mean of the 2 middle scores since, in this case, there is an even number of scores. The sorted array should be stored as a separate array, since option 7 should not be affected by this bonus option.

If your program does not compile, it will not be graded. Compile your code often. Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.

2 pts: DOES NOT USE GLOBAL VARIABLES/OBJECTS

2 pts: Array
       - (1 pt) Correctly declared and initialized in main.
       - (1 pt) Correctly passed as an argument to each function. 

3 pts: Functions
       - (1 pt) Options 1, 2, and 3
       - (1 pt) Options 4 and 5
       - (1 pt) Options 6 and 7

1 pt: Misc.
       - (.5 pts) Each menu option (other than exit) has a function call.
       - (.5 pts) Input error checking

2 pts: Style
       - (.5 pts) Good variable/function names
       - (.5 pts) Proper indentation/spacing
       - (.5 pts) Good comments (including header and function comments)
       - (.5 pts) No line wraps