CSCI 1300 - Program for Homework 11

The purpose of this homework is to help you and me gauge your skill in writing small programs that involve arrays. It is simpler than the other recent assignments, but I need you to do it entirely on your own (with help from instructors only). Think of it like a take-home exam.

Due date: midnight on Friday, Nov 22. However, please plan ahead and don't leave things until the last moment. To encourage this future planning: None of the instructors will offer help by e-mail or otherwise on Friday, Nov 22. Any problems that you run into on that day must be handled by yourself. So, try to complete this early so we can help with any problems.


This assignment will be graded automatically by running the program and comparing the output with the correct output.

Because of the automated grading, the output of your program must match the specification exactly. You must not add any extra features that will confuse the grader. For example, the program must not print directions to the user unless such directions are required by the specification.


The program is an interactive program that reads input from the keyboard. Several instructions (listed below) may be entered by the user. For each input, the program will give a short response printed to cout. Each response to cout is followed by a single endl.

One warning: The program must not try to store all the numbers in a single big array. In fact, I forbid you from having any array that is larger than 100 elements. Instead, you should create a frequency array which has indexes from [0] to [99]. A location, such as frequency[i] tells you how many times the number i has occurred in the input. This frequency array should be initialized to all zeros, and each time a number is read, the program will add one to the corresponding array location. For example, frequency[42] begins at zero. When one 42 is read, frequency[42] is increased to one. If another 42 is read, frequency[42] is increased to two, and so on. All of the statistics that you need to calculate can be computed based on the frequency array (so that you don't need to store all those numbers separately).

SAMPLE SESSION WITH THE PROGRAM: User input in the session is written in italic. Program output is written in bold:

     N 2
     N 2
     N 6
     N 5
     N 3


Read the command characters with an input statement like this (where command is a char variable):

    cin >> command;
Use a switch statement to control the action of the program based on the command character that has been read. If the command character was an N, then read the number with an input statement like this (where number is an integer variable):
    cin >> number;
Don't forget the break statement at the end of each case.