Case Study:

 

Create an Employee class for a basic payroll program to compute the net pay salary of hourly based employees. Your program should also find the average net pay for a small company. To define the class, include the appropriate data members, member functions, and access modifiers. For simplicity, use a constant tax rate of 30% to compute the tax amount. Employees that work over 40 hours will receive overtime pay of one and a half of their hourly rate for overtime hours worked. The output should display the name of each employee, hours worked, hourly rate, overtime pay, regular (gross) pay, tax amount, and net pay. The average net pay of all employees should also be displayed.

 For the purpose of this course I will NOT be coding this program but rather, look at the case study in terms of objects and plans. I will identify the object(s) and plan(s) needed to solve the problem and include data members and functions for objects. There will be much content along with some visual representation to better facilitate understanding.


PLANS

What is a Plan?

A plan is an abstraction of a concept, requirement, programming code, object, and other sub-plans. A plan has a goal or purpose within a particular time and context and can be integrated with other plans to build a larger plan.

Origin of Plans

The idea of plan used in programming builds on the concept of script and plans used for structured knowledge representation in natural language processing

Programming Plan

Plans are template-like solutions used in problem solving. A Plan is represented in programming as a set of 
code segments that together perform a task in solving a problem. Plans may be a single statement
 (e.g. Increment Plan), or may be more complex, consisting of several sub-plans e.g. Sort Plan [Ebrahimi, 92]. 
Programming knowledge can be represented by five cognitive levels: lexical, syntactic, semantic, schematic, 
and conceptual. The schematic level refers to groups of statements which together form a programming plan. 
The relationship between these plans is represented in a hierarchical format. 

In terms of PLANS there are several which are implemented in this program; Appended, Interleaved, and Branched. Each plan has its particular functionality towards operating each individual object based on their syntax.

Appended    

 

 

Interleaved

 

 

 

 

 

Branched

 

 

 

A plan that is operative sequentially.

 

A plan that is used to go back and forth within a particular plan. A plan that can be diverted to other plans based on their conditions.

Appended
A plan that is operative sequentially.

For Instance as follows:

Access the Payroll file
Payroll file
Once accessed, the function Calculate Gross Pay is called  

Calculate Gross Pay
Once the function has been called and compiles, the tax rate can be calculated

Calculate Tax
Next the function calculate tax is called and compiles, net pay can be calculated now

Calculate Net Pay
Next the function calculate net pay is called, compiles, and placed in an array; average net pay can now be calculated

Calculate Average Net Pay
The function is called and net pay is calculated

Interleaved
A plan that is used to go back and forth within a particular plan.

Some objects utilize data pending the result of the IF statement

The tax rate varies depending on the condition of the IF statement.

 

void payroll ::calculatetax(){     

if(grosspay >= 500)  taxrate = .30;

            else if(grosspay > 200.00)  taxrate = .20;

            else  taxrate = .10;

            if(maritalstatus == 'S' ||maritalstatus == 's')

                         taxrate = taxrate + .05;

            taxamount = grosspay * taxrate;   }//CALCULATETAX

Branched
A plan that can be diverted to other plans based on their results.

Example: void payroll::

Based on given data and through the completion of an IF statement, a function could lead to varied results.

 

 void payroll:: calculategrosspay(){      

if(hoursworked  >  40){

                         overtime = hoursworked - 40;

                         regularpay = hoursworked * hourlyrate;

                         overtimepay = overtime * (hourlyrate * 1.5);

                         grosspay = regularpay + overtimepay;   }//IF

else  grosspay = hoursworked * hourlyrate;   }//CALCULATEGROSSPAY


The Program!

 

1
Hosted by www.Geocities.ws