Homework 1 - Review cmps2010


The purpose of this homework assignment is to familiarize yourself with C++ (Functions, Pass By Value, Pass By Reference, Pointers, Dynamic Memory Allocation, Structures). For this homework assignment, you will be to create a menu based program for Employee records. The menu will prompt to either add a new employee, print one employee, print all employees, or exit.

* 1. Add new employee    *
* 2. Print one employee  *
* 3. Print all employees *
* 0. Exit                *
Enter Choice: 

For the Employee structure definition, the employee will have a static sized cstring for the employee's first and last name, an integer for the employee's hours worked, and a float for the employee's hourly payrate.
This program will use an Employee pointer to store the array of employees, and an integer to store the current count of employees.
For option 1, each time an employee is added, you will need to allocate a new temporary array with count + 1 employees, copy the current array into the temporary (memberwise assignment), deallocate the current, then set the current to point to the temporary. You will write a function called 'allocate' to do this, description below.
For option 2, you will prompt the user for which indexed employee to print. If the user ask for the first employee by entering 1, you will print the contents of the employee stored in the array at index 0. You will validate that the entered index is within range of the employee array (1<=index<=count). If the index is out of range, prompt the user again for a valid index.
For option 3, you will pass the employee array and the current count to a function that will traverse the array, print the members of each object, and calculate the $paycheck.00 (rate*hours) in monetary format.
For option 0, you will then deallocate the employee array if necessary, set the employee pointer to NULL, and exit the program.


Once completed, you will copy your source code into your depository directory: /2020_S19/wk1/hw1.cpp.

If you have any questions, feel free to ask me during office hours, before class, after class, email me, call me, or find me and I'd be happy to help. Also, there's the walk-in lab (SCI III rm 324) where there are tutors there to help if you cannot reach me