Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add sum and average into this program to calculate the net pay and then run it Make the sum and average thier own methods #include

Add sum and average into this program to calculate the net pay and then run it
Make the sum and average thier own methods #include
#include
#include
using namespace std;
class payroll{
ifstream fin;
char employeeid[12];
char employeename[20];
char maritalstatus;
int hoursworked,overtime;
double hourlyrate,overtimepay,regularpay,grosspay,taxrate,taxamount,netpay;
void calculategrosspay();
void calculatetax();
void calculatenetpay();
void printheadings();
void printdata();
public: payroll();
~payroll();
void printreport(); };
payroll::payroll(){
fin.open("payroll.dat"); }//CONSTRUCTOR
payroll::~payroll(){
fin.close(); }//DESTRUCTOR
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
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
void payroll :: calculatenetpay(){
netpay = grosspay - taxamount; }//CALCULATENETPAY
void payroll::printheadings(){
cout<>employeename>>employeeid>>maritalstatus>>hoursworked>>hourlyrate){
calculategrosspay();
calculatetax();
calculatenetpay();
printdata();
i++; }//WHILE
}//PRINTREPORT
void main(){
payroll employee;
employee.printreport(); }//MAIN

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions