Create a Text file containing the following data (without the headings):
Name
Wage Hours
Callaway, G 16.00 40
Hanson, P 15.00 48
Lasard, D 16.50 35
Stillman, W 18.00 50
Write a C++ program that uses the information in the file to produce the following pay report for each employee:
Name, Pay Rate, Hours, Regular Pay, Overtime Pay, Gross Pay
Compute regular pay as any hours worked up to and including 40 hours multiplied by the pay rate. Compute overtime pay as any hours worked above 40 hours times a pay rate of 1.5 multiplied by the regular rate. The gross pay is the sum of regular and overtime pay. At the end of the report, the program should display the totals of the regular, overtime and gross pay columns.
Code
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
ifstream inFile;
inFile.open("employeeInfo.txt");
string firstName,lastnamae,fullName;
double wage,hour;
double regularPay,overtimePay,grossPay;
if(!inFile)
{
cout<<"Error! File not
found..Exiting..."<<endl<<endl;
return 1;
}
cout<<fixed;
cout<<setprecision(2);
cout.width(15);cout << std::left <<
"Name";
cout.width(15);cout << std::right << "Pay
Rate";
cout.width(15);cout << std::right <<
"Hours";
cout.width(15);cout << std::right <<
"Regular Pay";
cout.width(15);cout << std::right <<
"Overtime Pay";
cout.width(15);cout << std::right <<
"Gross Pay"<<endl;
while(inFile>>firstName>>lastnamae>>wage>>hour)
{
fullName=firstName+"
"+lastnamae;
if(hour>40)
{
regularPay=40*wage;
overtimePay=(hour-40)*(1.5*wage);
}
else
{
regularPay=hour*wage;
overtimePay=0;
}
cout.width(15);cout <<
std::left << fullName;
cout.width(15);cout <<
std::right << wage;
cout.width(15);cout <<
std::right << hour;
cout.width(15);cout <<
std::right << regularPay;
cout.width(15);cout <<
std::right << overtimePay;
cout.width(15);cout <<
std::right << (regularPay+overtimePay)<<endl;
}
return 1;
}
output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Hours Callaway, G 16.00 40 Hanson, P 15.00 48 Lasard, D 16.50 35 Stillman,...
Create a Text file containing the following data (without the headings): Name Wage Hours Callaway, G 16.00 40 Hanson, P 15.00 48 Lasard, D 16.50 35 Stillman,...
"Multiple Function Returns Using Memory Pointers" Contents of employee.dat... copy paste and create a file (employee.dat) 123-45-6789 Kirk James 44.7 88.99 0.0175 124-89-0007 Bond Jane 45.6 65.75 0.04 405-77-8911 Puff Blossom 40 33.88 0.03 405-10-9871 Puff Buttercup 41.2 45.66 0.047 223-03-8761 Puff Bubbles 37.8 33.44 0.015 980-11-2201 Joneski Kasey 23.1 10.77 0.033 115-88-7619 Crooke I.M.A. 25.4 88.75 0.02 777-00-1232 Smith Alias 43.5 22.3 0.034 345-89-0022 DeMann Stan 56.7 29.45 0.065 210-37-1192 Jones Jeane 48.9 20.33 0.025 103-22-4321 Smith Alias 33.5...
The Excel file Payroll Data provides hourly salaries for a group of employees. Create an Excel template that allows the user to select an employee by employee ID, enter the number of regular hours and overtime hours worked, and display a payroll summary with the employee name, gross pay, federal tax, state tax, Social Security, Medicare withholding deductions, and net pay. Assume that the federal tax rate is 11%, the state tax rate is 2.385%, Social Security withholding is 6.2%,...
Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...
In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...