Homework 6 - More Arrays

Due: Wednesday, November 9, 2011 at 5:00pm

Name your files hw6_<problem>.cpp, such as hw6_1.cpp. Email all the cpp files to my account.

  1. (10 points) - Convert Homework 5, Problem 2 to use functions instead of having all the menu operations in main(). You will declare an array and an array current size variable in main() and pass it to the functions. The required functions are: Update main() to call these functions. For the calculation functions, main() should print the return value to the screen.
  2. (10 points) - This program will create a simple employee paycheck calculator using parallel arrays and an array of C-style strings. Use the following menu for the program:
      Welcome to the Employee Paycheck Calculator
      ===========================================
      1.  Add employee record(s) to the database
      2.  Print all employee records
      3.  Print the paycheck for one employee
      4.  Print paychecks for all employees
    
      0.  Exit
      ===========================================
      Enter selection:
    
    Each employee will have three pieces of data: a name, a pay rate and hours worked this pay period. These will be stored in the following parallel arrays: Each index in the array will correspond to a particular employee, e.g., index 0 of each array will correspond to the first employee. The arrays must all be declared in main()'s scope and passed to the functions. Use a partially filled array for each array, although the current size variable can be shared among all arrays since each array will contain the same number of employees.

    To support each option, main() will make function calls. Before calling the functions for Options 2, 3, and 4, validate that the current number of employees is greater than 0. If it is not, tell the user to select Option 1 first. Do NOT reset the current number of employees after selecting Options 2, 3, or 4.

    For Option 3, you will ask the user to select an index number corresponding to the employee whose paycheck is to be printed out. You MUST validate that the user has selected a valid index number (0 to current size - 1). If the user has selected an invalid index number, print an error message and break out of the select statement (which will trigger the next iteration of the menu loop). When the user has selected a valid index, rather than passing the arrays to the printEmployeePaycheck() function, you will be passing the values at the selected index, e.g., name[0] instead of the whole name array if the user selected index 0.

    You will have at least the following four functions (you may add more functions if you wish) to support the options:

Email your files to me.