Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Insurance and payroll code (http://www.go4expert.com/forums/insurance-payroll-code-t18488/)

 Prof. Krauf 12Jul2009 05:51

Insurance and payroll code

I'm just sort of begginning here and this C++ stuff is overwhelming.
Let's see I'm trying to make a code file where I would need to
calculate a pay rate based on the person's position. Then that said
function should calculate the gross pay (rate *hours worked). The function should return gross pay to the main routine.

I would aslo need an Insurance function for Determining the insurance rate based on the type. I think I might have to use an array here in the main routine and pass it to this function.
Then calculate the insurance deduction based on the rate times the gross pay and return insurance deduction to
main routine.
I'm thinking something should look/involve this.

Positions: Rate:
M = Manager........................................... .............. 40.00
S = Supervisor .................................................. .... 20.00
E = Employee .................................................. ..... 10.00
Insurance Type: Rate:
1 = Single .................................................. .............. 0.02
2 = Single with children ........................................... 0.03
3 = Married........................................... ................... 0.04
4 = Married with Children ........................................ 0.05
Bonus: Rate:
Gross >= 5000 ................................................ 1000.00
Gross is equal to 3000 and <=4999 ................... 600.00
Gross < 3000 .................................................. ...... 0.00
Tax: Rate:
Gross >= 7000 .................................................. ...... 0.15
Gross is equal to 4000 and <= 6999 ..................... 0.10
Gross is equal to 2000 and <= 3999 ..................... 0.05
Gross is < 2000 .................................................. ... 0.00
Miscellaneous: Rate:
Medicare deduction ........................................... 100.00
Social Security Tax ............................................... 0.05

and here's some code I have where I attempted this.

Code:

```#include <iostream> using namespace std; int main() { //declare variables double pay; double rate; int OT; int Hours;   //get input from user cout << "Input hours worked: "; cin >> Hours; cout << "Enter pay: "; cin >> rate; //determine overtime if(Hours > 40) { OT = Hours - 40; Hours = 40; } else OT = 0; //calculate pay         pay = (rate * Hours) + (OT * rate * 1.5); cout << "regular hours " << Hours << endl; cout << "overtime " << OT << endl; cout << "pay " << pay << endl; system ("pause"); return 0; }```

 xpi0t0s 12Jul2009 20:36

Re: Insurance and payroll code

What input did you give the program, and what output did you get?

 All times are GMT +5.5. The time now is 05:53.