Homework 5 - File I/O and Arrays: Part 2

Due: Wednesday October 27, 2010 at 5:00pm
NOTE: No late assignments will be taken after Saturday October 30, so the solutions can be posted to study before Midterm 2.

Name your file hw5.cpp and email it to my account.

Modify the class menu program to work on an array as follows. The menu will print this to the screen:

  Welcome to the CS221 Homework 5 Menu
  ===============================================
  1.  Enter a list of integers from the keyboard.
  2.  Read a list of integers from a file.
  3.  Multiply all integers in the list.
  4.  Calculate the average and standard deviation
      for all the integers in the list.

  0.  Exit
  ===============================================
  Enter selection:
The list read in by either option 1 or 2 should be saved in an array. Use this saved array to do options 3 and 4. Options 3 and 4 should print out an error if they are selected before input is given (via option 1 or 2).

Options 3 and 4 should use a calculation function (e.g. calc_product, calc_average, calc_deviation) that takes an array and the size of the array and returns the appropriate calculation. Recall from Homework 4 that the standard deviation calculates the sum squared error (sse) then divides by the size - 1, then takes the square root.

Required elements:

You may opt to use additional functions to support your menu, such as input functions for options 1 and 2 or a menu function to print the menu. These are not required for the assignment, but should you opt to use them, they should be syntactically and logically correct.

Use the following files as input to option 2: hw5_input1 hw5_input2