in c++In this exercise, we will read in a data file of employees (file is furnished to you, “employee.dat”):Employee SSNEmployee Last NameEmployee First NameHours WorkedPay Per HourPersonal Income Tax Rate You assignment’s logic is to:Read in the records from the file,Pass the Hours Worked, Pay Per Hour, Personal Income Tax Rate to a single function to determine:Whether or not overtime pay is computed (anything over 40 hours is overtime at 1.5 times the regular pay). Compute any overtime pay at 1.5 times pay rateCompute the regular pay at regular hours (40 hours or less)Compute the gross pay (Regular Pay plus any overtime pay)Compute the personal income taxes withheldCompute Net Pay (gross pay minus personal income taxes withheld)Pass ALL these values BACK to the main calling routine from this one function.Display:the Employee SSN,Last Name, First Name,Total Hours,Regular Hours,Overtime Hours (if any),Pay Per Hour,Personal Income Tax Rate,Regular Pay, Overtime Pay (if any),Gross Pay,Withheld Income Taxes,Net Pay.this is my .dat file123-45-6789 Kirk James 44.7 88.99 0.0175124-89-0007 Bond Jane 45.6 65.75 0.04405-77-8911 Puff Blossom 40 33.88 0.03405-10-9871 Puff Buttercup 41.2 45.66 0.047223-03-8761 Puff Bubbles 37.8 33.44 0.015980-11-2201 Joneski Kasey 23.1 10.77 0.033115-88-7619 Crooke I.M.A. 25.4 88.75 0.02777-00-1232 Smith Alias 43.5 22.3 0.034345-89-0022 DeMann Stan 56.7 29.45 0.065210-37-1192 Jones Jeane 48.9 20.33 0.025103-22-4321 Smith Alias 33.5 19.67 0.063

Question
Asked Nov 30, 2019
4 views

in c++

In this exercise, we will read in a data file of employees (file is furnished to you, “employee.dat”):

  1. Employee SSN
  2. Employee Last Name
  3. Employee First Name
  4. Hours Worked
  5. Pay Per Hour
  6. Personal Income Tax Rate

 

You assignment’s logic is to:

  1. Read in the records from the file,
  2. Pass the Hours Worked, Pay Per Hour, Personal Income Tax Rate to a single function to determine:
  3. Whether or not overtime pay is computed (anything over 40 hours is overtime at 1.5 times the regular pay). Compute any overtime pay at 1.5 times pay rate
  4. Compute the regular pay at regular hours (40 hours or less)
  5. Compute the gross pay (Regular Pay plus any overtime pay)
  6. Compute the personal income taxes withheld
  7. Compute Net Pay (gross pay minus personal income taxes withheld)
  8. Pass ALL these values BACK to the main calling routine from this one function.
  9. Display:
    • the Employee SSN,
    • Last Name, First Name,
    • Total Hours,
    • Regular Hours,
    • Overtime Hours (if any),
    • Pay Per Hour,
    • Personal Income Tax Rate,
    • Regular Pay, Overtime Pay (if any),
    • Gross Pay,
    • Withheld Income Taxes,
    • Net Pay.

this is my .dat file

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 19.67 0.063
check_circle

Expert Answer

Step 1

Read data from employee.dat file.

The employee.dat file contains SSN number of the employee, last name of the employee, first name of the employee, total hours worked by an employee, pay per hour of an employee, income tax rate of an employee.

Create a function named EmpCalculations to calculate the regular hours, regular pay, overtime hours, overtime pay, gross pay, personal income tax, and net pay of an employee.

Regular hours are less than or equal to 40 hours.

Overtime hours are calculated when regular hours is greater than 40. If the regular hour is less than or equal to 40 then there are 0 overtime hours.

Regular pay is calculated by multiplying regular hours by pay per hour.

Overtime pay is calculated by multiplying of overtime hours by 1.5 of pay per hour.

Gross pay is the addition of regular pay and overtime pay.

Withheld personal income tax is calculated by multiplying gross pay by the personal income tax rate of an employee.

Net pay is calculated by subtracting gross pay by withheld personal income tax.

To access EmpCalculations() function values you can declare all function variable as global variable.

The global variables statement is written just after the header file statement.

A global variable is accessible to all the functions and any portion of a program.

The global variable store its value throughout the life of the program.

 

Declaration of the global variable is the same as the local variable.

float OTHour, RegHour, OTPay, RegPay, GrossPay, WithheldIT, NetPay;

 

Display all the values in the main function.

Step 2

The sample program is:

//including essential header files

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

 

//global variabal declaration

float OTHour, RegHour, OTPay, RegPay, GrossPay, WithheldIT, NetPay;

 

//function declaration

void EmpCalculations(float *WorkHours, float *PPHour, float *PITaxRate);

 

//main function

int main()

{

//declare variables to store employee details

string EmpSSN, EmpLastName, EmpFirstName;

float WorkHours, PPHour, PITaxRate;

 

//ifstream to read file named employee.dat

ifstream myfile;

myfile.open("employee.dat");

//while loop to go through all the data in file

while (myfile >> EmpSSN >> EmpLastName >> EmpFirstName >> WorkHours >> PPHour >> PITaxRate)

{

    //display value at the console

    cout << EmpSSN << " " <<  EmpLastName << " " << EmpFirstName << " " << WorkHours << " " << PPHour << " " << PITaxRate << endl;

   

    //calling function

    EmpCalculations(&WorkHours, &PPHour, &PITaxRate);

   

    //display Regular Hours

    cout<<"Regular Hours: "<< RegHour<<endl;

    //display overtime Hours

    if (OTHour>0)

    {

        cout<<"Overtime Hours: "<< OTHour <<endl;

    }

    //calculate regular pay

    cout<<"Regular pay: "<< RegPay <<endl;

   

    if (OTPay>0)

    {

        cout<<"Overtime pay: "<< OTPay <<endl;

    }

    cout<<"Gross pay: "<< GrossPay <<endl;

    cout<<"Withheld Income Tax: "<< WithheldIT <<endl;

    cout<<"Net pay: "<< NetPay <<endl;

    cout << endl;

}

} //End of while

//End of main

 

//function definition

void EmpCalculations(float *WorkHours, float *PPHour, float *PITaxRate)

{

//float reghours, overtime, reg_pay, over_pay, tax_rate;

if(*WorkHours > 40)

{

    RegHour = 40;

    OTHour = (*WorkHours)-40.0;

}

else{

    RegHour = *WorkHours;

    OTHour = 0;

}

//calculate regular pay

RegPay = RegHour*(*PPHour);

//calculate overtime pay

if(OTHour > 0)

{

    OTPay = 1.5*(*PPHour)*OTHour;

}

else{

    OTPay = 0;

}

//calculate gross pay

GrossPay = RegPay + OTPay;

//calculate with held income tax

WithheldIT = GrossPay * (*PITaxRate);

//calculate net pay

NetPay = GrossPay - WithheldIT;

}

Sample output is:

123-45-6789 Kirk James 44.7 88.99 0.0175
Regular Hours: 40
Overtime Hours: 4.7
Regular pay: 3559.6
Overtime pay: 627.38
Gross pay: 4186.98
Withheld Income Tax: 73.2721
Net pay: 4113 . 71
124-89-0007 Bond Jane 45.6 65.75 0.04
Regular Hours: 40
Overtime Hours: 5.6
Regular pay: 2630
Overtime pay: 552.3
Gross pay: 3182.3
Withheld Income Tax: 127.292
Net pay: 3055.01
405-77-8911 Puff Blossom 40 33.88 0.03
Regular Hours: 40
Regular pay: 1355.2
Gross pay: 1355.2
Withheld Income Tax: 40.656
Net pay: 1314.54
help_outline

Image Transcriptionclose

123-45-6789 Kirk James 44.7 88.99 0.0175 Regular Hours: 40 Overtime Hours: 4.7 Regular pay: 3559.6 Overtime pay: 627.38 Gross pay: 4186.98 Withheld Income Tax: 73.2721 Net pay: 4113 . 71 124-89-0007 Bond Jane 45.6 65.75 0.04 Regular Hours: 40 Overtime Hours: 5.6 Regular pay: 2630 Overtime pay: 552.3 Gross pay: 3182.3 Withheld Income Tax: 127.292 Net pay: 3055.01 405-77-8911 Puff Blossom 40 33.88 0.03 Regular Hours: 40 Regular pay: 1355.2 Gross pay: 1355.2 Withheld Income Tax: 40.656 Net pay: 1314.54

fullscreen
Step 3

Output conti...

405-10-9871 Puff Buttercup 41.2 45.66 0.047
Regular Hours: 40
overtime Hours: 1.2
Regular pay: 1826.4
Overtime pay: 82.188
Gross pay: 1908.59
Withheld Income Tax: 89.7036
Net pay: 1818 . 88
223-03-8761 Puff Bubbles 37.8 33.44 0.015
Regular Hours: 37.8
Regular pay: 1264.03
Gross pay: 1264.03
Withheld Income Tax: 18.9605
Net pay: 1245. 07
980-11-2201 Joneski Kasey 23.1 10.77 0.033
Regular Hours: 23.1
Regular pay: 248.787
Gross pay: 248.787
Withheld Income Tax: 8.20997
Net pay: 240 . 577
help_outline

Image Transcriptionclose

405-10-9871 Puff Buttercup 41.2 45.66 0.047 Regular Hours: 40 overtime Hours: 1.2 Regular pay: 1826.4 Overtime pay: 82.188 Gross pay: 1908.59 Withheld Income Tax: 89.7036 Net pay: 1818 . 88 223-03-8761 Puff Bubbles 37.8 33.44 0.015 Regular Hours: 37.8 Regular pay: 1264.03 Gross pay: 1264.03 Withheld Income Tax: 18.9605 Net pay: 1245. 07 980-11-2201 Joneski Kasey 23.1 10.77 0.033 Regular Hours: 23.1 Regular pay: 248.787 Gross pay: 248.787 Withheld Income Tax: 8.20997 Net pay: 240 . 577

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Let’s say that you installed Windows Server 2016 on VM1 and you added VM1 to the Adatum.com domain. ...

A: Ways for virtual machine using both device and credential guardAfter installing Windows server 2016 ...

question_answer

Q: Please study / review chapters 03 and 06 before you attempt to do this project. Design two pseudocod...

A: Pseudocode:Pseudocode for “main ()” function:Start the “main ()” functionRead the first number from ...

question_answer

Q: What is the SQL query commands to create the COURSE table (attached) with appropriate attributes and...

A: Course table:COURSE(COURSE_TYPE, DEPARTMENT_ID, COURSE_TITLE, COURSE_DESCRIPTION, COURSE_TYPE_CODE )...

question_answer

Q: Compiler returning errors with calculations and declarations. Screenshot of File.txt included.  ...

A: The code is working fine as I have tested it and the Output is attached at the end.Code://importing ...

question_answer

Q: Write a wholly creative quiz program that consists of three original questions that you make up acco...

A: As here, no programming language is specified. So, we are providing the solution in java.The below g...

question_answer

Q: 1:02 PM COmputer ScieNTE QUESTIONS ama answers/ What is... '@ Question: What is the output of the fo...

A: Explanation:The “==” sign in the “if” condition compare the two string reference types “abc” and “xy...

question_answer

Q: Did I correctly perform the SQL query below (photo attached): A query that contains the GROUP BY cla...

A: Answer:“Yes”, the given query is correct.

question_answer

Q: 1. Explain what the CPU should do when an interrupt occurs. Include in your answer the method the CP...

A: Interrupt handling by the Central Processing Unit (CPU)An interrupt is a process through which modul...

question_answer

Q: Create a MySQL Database called “CSC306Class”. Create three (3) tables in the database called “studen...

A: CREATE DATABASE:A new SQL database is created using the CREATE DATABASE statement.Syntax:CREATE DATA...