Basic Payroll Program using C++
This program will teach how to compute a basic payroll, simple formulas applied on this program like deductions, gross pay and net income.
So, first is the header declarations that we are going to use in our program.
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <conio.h>
#include <windows.h>
using namespace std;
Second is the struct to be used in calling our functions.
void textcolor(int color);
struct payroll
{
string name;
float rate_per_day,sss,philhealth;
int total_days_work;
};
then a functions with arguments to compute the gross, deduction and net income
float compute_gross(float rate_per_day, float days_worked)
{
return(rate_per_day * days_worked);
}
float compute_net(float rate_per_day,
float days_worked,
float sss,float philhealth)
{
float gross_pay=0.00, deductions=0.00, net_income=0.00;
gross_pay = (rate_per_day * days_worked);
deductions = (sss+philhealth);
net_income = (gross_pay - deductions);
return(net_income);
}
float compute_deductions(float sss,float philhealth)
{
return(sss+philhealth);
}
the main method.
main()Enjoy and Happy Coding!
{
payroll employee;
cout << "\t Simple Payroll System ";
cout << "\n\n";
cout << " Enter Employees Name : ";
getline(cin,employee.name);
cout << " Enter Employees Rate/Day : ";
cin >> employee.rate_per_day;
cout << " Enter Number of Days Worked : ";
cin >> employee.total_days_work;
cout << "\n\n";
cout << " == DEDUCTIONS == ";
cout << "\n\n";
cout << "\nSSS Contribution : ";
cin >> employee.sss;
cout << "PhilHealth Contribution : ";
cin >> employee.philhealth;
cout << "\n\n";
cout << fixed << setprecision(2);
cout << " Total Deductions => Php "
<< compute_deductions(employee.sss,
employee.philhealth);
cout << "\n";
cout << " Monthly Gross Income : Php " <<
compute_gross(employee.rate_per_day,
employee.total_days_work);
cout << "\n\n";
cout << "\n Employees Name : " << employee.name;
cout << "\n Monthly Net Income : Php " <<
compute_net(employee.rate_per_day,
employee.total_days_work,
employee.sss,employee.philhealth);
cout << "\n\n";
system("pause");
}
Basic Payroll Program using C++
Reviewed by code-dev
on
8:30 PM
Rating:
Good afternoon, can you pls help to convert of your code c program
ReplyDelete