Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Heres the code from Payroll5.cpp #include #include #include using namespace std; // function prototypes // instructions()- describes the program usage to the user void instructions();

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Heres the code from Payroll5.cpp

#include

#include

#include

using namespace std;

// function prototypes

// instructions()- describes the program usage to the user

void instructions();

// reportTitle() displays the payroll report titles in columnar format

void reportTitle();

//displays the information for each employee

void displayEmployeeInfo(string name,double hourly,double hours,double taxrate,double gross_income,double net) ;

// displays the total gross and net amounts

void totalAmounts(double total_gross,double total_net);

// calculate the gross income of the employee

double calculateGross(double hours_worked,double hourly_payrate);

// calculate the net income of employee

double calculateNet(double gross_pay,double taxrate);

int main() {

string name;

double hourly, hours, rate;

double net_income,gross_income, total_net,total_gross;

ifstream file("payroll.txt");// open the file in read mode

// initialize accumulators variables

total_gross = 0.0;

total_net=0.0;

// display a descriptive message

instructions();

if(file.is_open())

{

// display column headings

reportTitle();

//attempt to input the name on the first input line

getline(file,name,'#');

// test that name contains at least one character

while(!file.eof() && name.length()>0)

{

// input the remaining doubles on the input line

file>>hourly>>hours>>rate;

// set input beyond the current line

file.ignore(100,' ');

// calculate gross income

gross_income = calculateGross(hours,hourly);

// calculate net pay

net_income = calculateNet(gross_income,rate);

//display info for this employee

displayEmployeeInfo(name,hourly,hours,rate,gross_income,net_income);

//update accumulation variables

total_gross = total_gross + gross_income;

total_net =total_net + net_income;

//attempt to input next name

getline(file,name,'#');

}

}else

cout

// display totals

totalAmounts(total_gross,total_net);

file.close(); // close the file

return 0;

}

// instructions() describes the program usage to the user

void instructions()

{

// display program instructions

cout

}

// reportTitle() displays the payroll report titles in columnar format

void reportTitle()

{

// set program formatting

cout

// display report titles

cout

cout

}

//displays payroll information for an employee

void displayEmployeeInfo(string name,double hourly,double hours,double taxrate,double gross_income,double net)

{

cout

cout

}

// calculate the gross income of the employee

double calculateGross(double hours_worked,double hourly_payrate)

{

if(hours_worked > 40)

return(40*hourly_payrate + ((hours_worked-40) * hourly_payrate * 1.5));

else

return(hours_worked*hourly_payrate);

}

// calculate the net income of employee

double calculateNet(double gross_pay,double taxrate)

{

return(gross_pay - ((gross_pay*taxrate)/100));

}

// displays total gross and total net for the input file

void totalAmounts(double total_gross,double total_net){

cout

}

// end of program

This assignment is a continuation of the last assignment whereby we process employee payroll data in the file payroll.txt to produce a report that calculates the gross and net pay for each employee as well as the total-gross and total net pay for all employees in the file. The input and the algorithm for this program are identical to the previous exercise except that we're going to ask you to implement some portions of the algorithm with additional functions that utilize reference parameters. Assignment 6 Statement: Write a program in a file named Payroll6.cpp that creates the same output and implements the same algorithm as Payro115.cpp in the previous exercise. In particular, the functions instructions, reportTitle), displayEmployeeInfo), and totalAmounts) should be present in this solution as well as two additional func- tions named readData) and calculate() that manipulate reference parameters. The function readData) should read the name, hourly, hours and rate from the ifstream where these variables have the same meaning as they did in Payro115.cpp and return these updated values to the invoking function. The function calculate ) determines the gross and net in addition to updating the total gross and the total_net based upon the hourly, hours and rate and likewise returns the values to the mainO. As with Payro115.cpp, the program should perform all input from the sequential file payroll.txt and perform all output to the monitor. Our specifications and variables are not going to change with this solution, however our use of functions will need to include those that use reference parameters in addition to the functions that we've used that have used value parameters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Question

List the functional consequences of PTSD.

Answered: 1 week ago