Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please edit for errors so that I am able to compile and run to show payroll repo

ID: 3588978 • Letter: P

Question

please edit for errors so that I am able to compile and run to show payroll report for C++ usi nc DEVC++

#include<fstream>

#include<iostream>

#include<iomanip>

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(); }//DECONSTRUCTOR

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)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<<setw(45)<<"-MEGHAN'S PAYROLL REPORT-"<<endl;

cout<<"-----------------------------------"<<endl;

cout<<"NAME ID HW OT RT-PAY OT-PAY GROSS TAX NET"<<endl;

cout<<"------------------------------------------------"<<endl;

}//PRINTHEADINGS

void payroll::printdata(){

cout<<setprecision(2)<<setiosflags(ios::fixed|ios::showpoint);

cout<<setw(6)<<employeename<<setw(12)<<employeeid<<setw(4)<<hoursworked

<<setw(3)<<overtime<<setw(8)<<regularpay<<setw(8)<<overtimepay<<setw(8)

<<grosspay<<setw(8)<<taxamount<<setw(8)<<netpay<<endl; }//PRINTDATA

void payroll::printreport(){

int i=0;

printheadings();

while(fin>>employeename>>employeeid>>maritalstatus>>hoursworked>>hourlyrate){

calculategrosspay();

calculatetax();

calculatenetpay();

printdata();

i++; }//WHILE

}//PRINTREPORT

void main(){

payroll employee;

employee.printreport();}//MAIN

Explanation / Answer

The problem may be due to main() function. Main function should be int main() and return;

Here I paste the edited code. Try this. If you have still problem, put a comment. I have compiled it in Eclipse IDE and g++ linux command.

/*******************************/

/*
* payroll.cpp
*
* Created on: 09-Oct-2017
*      Author: kuhu
*/

#include<fstream>

#include<iostream>

#include<iomanip>

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(); }//DECONSTRUCTOR

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)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<<setw(45)<<"-MEGHAN'S PAYROLL REPORT-"<<endl;

cout<<"-----------------------------------"<<endl;

cout<<"NAME ID HW OT RT-PAY OT-PAY GROSS TAX NET"<<endl;

cout<<"------------------------------------------------"<<endl;

}//PRINTHEADINGS

void payroll::printdata(){

cout<<setprecision(2)<<setiosflags(ios::fixed|ios::showpoint);

cout<<setw(6)<<employeename<<setw(12)<<employeeid<<setw(4)<<hoursworked

<<setw(3)<<overtime<<setw(8)<<regularpay<<setw(8)<<overtimepay<<setw(8)

<<grosspay<<setw(8)<<taxamount<<setw(8)<<netpay<<endl; }//PRINTDATA

void payroll::printreport(){

int i=0;

printheadings();

while(fin>>employeename>>employeeid>>maritalstatus>>hoursworked>>hourlyrate){

calculategrosspay();

calculatetax();

calculatenetpay();

printdata();

i++; }//WHILE

}//PRINTREPORT

int main(){

payroll employee;

employee.printreport();
return 0;
}//MAIN