Payroll Program: Part Two

This great image can be found at www.entrepreneur.com.

This great image can be found at http://www.entrepreneur.com.

Over the past several weeks I’ve been in the process of coding a payroll console program in the high level programming language C++.  To facilitate this activity I’ve been using the Dev-C++ compiler.

Progress has been a bit slow and painful, but that’s to be expected.  Much like learning a foreign language it would be foolish to think you can learn the intricate details of  any programming language over night.  C++ is no exception to that rule.  Still I have made progress, and the program has continued to evolve.

I thought I’d post a quick update to reveal some of what I’ve accomplished, a few of the hard lessons I’ve had to learn, and point out a little of what may be coming in the future.

Previous Work On Project

  1. Coded a simple program capable of accepting accounting data entry from the user and providing output containing the following; gross pay, tax amount, net pay.
  2. Revised program to read data from a text file, and executed program using redirection from a command prompt.
  3. Revised program once more to include the fstream library, read data from an input file, and echo the data to the display using a console window.
  4. Added logic for the program to identify the marital status of employees, and adjust the amount of tax withheld accordingly.
  5. Gave the program the ability to calculate overtime hours, overtime pay, and display the information with total net pay.

In its present state the program appears as follows:

Code

 Payroll4

Output

PayrollOutput4

Lessons Learned

Most of the lessons I learned were simple in nature; with a bit more attentiveness I may have avoided the errors that led to them, which would have saved me a lot of time and frustration.

  1. If you create a new project, and borrow the code from it’s previous version, remember to update the name of any data files that may be hard coded in the source code.
  2. Also, related to item number 1, if you direct a program towards an input file make sure the input file is actually present within the correct directory.
  3. When using a while loop, and attempting to get a program to detect and display a variety of characters (in the char data type), it helped to use two equal signs as the logical operator (as in ms == ‘ms’;).  Dual equal signs represent a true equality in C++.  Without them the program assigned a marital status of (for Single) for each of the employees despite what was indicated in the input file.

In general, I’m happy with how this project is coming along.  However, in the near future I think the output could use a bit cleaner presentation.  For example a header, maybe some names for the employees, and vertical alignment of the amounts shown.  Future post will describe my progress on this project.  Thanks for reading.

Advertisements

Join the fray...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s