Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 5 (Worth 4%) due Friday March 11

 

New Concepts to be applied for the assignment

  1. Problem decomposition through the use of program modules (functions and procedures)

  2. One dimensional arrays

Writing a salary management program

For this assignment you are to write a program that allows a manager to track and manage a list of employee salaries for a small company.  The full version of the program will allow the user to: enter a set of salaries, display the salaries of all employees as well and show some statistics about the pay scales.   You should start by declaring a one-dimensional array of real values (because fractional dollar values will be tracked) in the main procedure to store the employee salaries.   You will have to pass this array as a parameter to the various procedures and functions in your program.

Grading: Working submissions

Assignments that receive a 'C+'

After declaring the array, each element will be initialized to some default starting value (such as zero).  Next the program will prompt the user to enter in each salary checking that no invalid values have been entered.  An invalid value would be a salary would either be one that is negative or one that exceeds $999,999,999.99.   If such a value has been entered the program will display an appropriate error message and it will continue to prompt the user for the salary until a valid value has been entered.  Finally the program will show all employee salaries onscreen.  Although you do not have to make your output identical to the one in the sample program it should be neat and presentable in order for you to get credit for your work.

Additional capabilities

Implementing features #1 - #4 will yield a grade increase of one 'step' (e.g., 'C+' to 'B-').  Implementing feature number #5 will yield a grade increase of two steps.  These extra features can be implemented in any order and in any combination that you wish.  Implementing all five features will yield a grade increase of six steps ('C+' to 'A+').

  1. Compute the average salary: Implement a function or procedure that will determine the average employee salary and display it onscreen.

  2. Find the lowest paid employee: Implement a function or procedure that finds and displays onscreen the minimum salary in the list.

  3. Find the highest paid employee: Implement a function or procedure that finds and displays the maximum salary in the list.

  4. Increase the number of salaries that can be tracked from 10 to 100.  In order for you to receive credit for this extra feature you must hand in two versions of your assignment, one with a list of 10 elements and another with a list of 100 elements.  You cannot simply create one version of the program that works with only 100 employees.    Hint: There is a hard way of doing this an and easy way.  Think back the lectures when I first talked about writing programs and good style for a clue as to what the easy way is.

  5. Determine the number of employees that fall within different salary ranges.  The program will count the number of employees that fall within each of the following ranges:

Salary range

Less than $20,000

$20,000 to less than $40,000

$40,000 to less than $80,000

$80,000 and above

Program modules (functions or procedures that must be implemented in the full version of the program):

  1. "initialize": To initially set the array elements to some starting values.
  2. "displayAll": Shows all employee salaries onscreen.
  3. "inputSalaries": Steps through the array and prompts the user to enter in the salary for each employee.
  4. "displayRanges": Shows the salary ranges as well as the number of employees whose salary falls within a particular range.
  5. "findMin": Finds the salary of the lowest paid employee.
  6. "findMax": Finds the salary of the highest paid employee.
  7. "calculateAverage": Determines the average salary of all employees.

Also you will need a function or procedure that counts the number of salaries that fall within different pay ranges.  This should be accomplished by implementing a single module that works for all salary ranges rather than writing a separate one for each salary range.  It is okay if you wish to write additional functions or procedures (besides the two listed above) in order to complete your assignment.  How you wish to structure the remainder of your program is up to you, just make sure that your solution is guided by good design principles e.g., avoid putting all the code into a single function or procedure (especially the main procedure), each function or procedure should have a well defined task that gives it a clear purpose.

Grading: Non-working submissions

D submissions:

The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements but it does compile.

D- submissions:

The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements and it does not compile.

Other submission requirements

  1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step or more if your submission was implemented using bad style conventions (e.g., 'A' to 'A-' for employing poor naming conventions for identifiers, insufficient documentation, the use of global variables or non-modular design).

  2. Include a README file in your submission:  For this assignment your README file must indicate what grade level has been completed (e.g., A, B or C) as well as which of the above features have been implemented.  This will allow your marker to quickly determine what he or she must look for and speed up the marking process.

  3. Assignments (source code and the README file) must be electronically submitted via submit.  In addition a paper print out of all the source code (files that end in the "dot-p" suffix) and the README must be handed into the assignment drop box for the lab that you are registered in (located on the second floor of the Math Sciences building).  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and scan through your source code.

Sample Executable

You can run a sample executable called "salaryManager" which can be found in Unix in the directory: /home/231/assignments/assignment5