C programming windows console application visual studioSolut

C++ programming windows console application visual studio

Solution

Please find the below program which will help you to fetch the output as per your need:

/******************payroll.cpp *************************/

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using namespace std;
int main()
{

// declare variables

double hoursWorked = 0.0;
double rateOfPay = 0.00;
double grossPay = 0.0;
string name;
double fedTax = 0.0;
double netPay = 0.0;
char married = \"Y\";
int dep = 0;
double deduct = 0.0;
int health = 0;
double price = 0.0;

// declare input and output file streams

ifstream inFile;
ofstream outFile;

// open the files for input and output

inFile(C:\\\\payin.txt)
outFile(C:\\\\payroll.dat)

// set format manipulators

cout << fixed << showpoint;
cout << setprecision(2);

// get input data from payin.txt

inFile >> hoursWorked;

inFile >> rateOfPay;

infile >> dep;

infile >> married;

infile >> health;

getline(inFile, name);

// processing statements
grossPay = hoursWorked * rateOfPay;

// use nested if to determine deductions
if (married = \'Y\')
{
if (dep > 0)
{
deduct = 16;
deduct = deduct + (12 * dep);
grossPay = grossPay - deduct;
}
else
{
deduct = 16;
grossPay = grossPay - deduct;
}
}
else
{
deduct = 10;
grossPay = grossPay - deduct;
}

// Determine the cost of the health package selected.
// This is a pretax deduction

switch(health)
{
case 0:
grossPay = grossPay - 0;
price = 0.0;
break;
case 1:
grossPay = grossPay - 18.00;
price = 18.00;
break;
case 2:
grossPay = grossPay - 22.00;
price = 22.00;
break;
case 3:
grossPay = grossPay - 28.00;
price = 28.00;
break;
case 4:
grossPay = grossPay - 33.00;
price = 33.00;
break;
default:
grossPay = grossPay - 0;
price = 0.0;
}

// Decide here how much federal tax an employee should pay

if (grossPay <= 400.00)
fedTax = grossPay * .12;
if (grossPay > 400.00)
fedTax = grossPay * .18;

// calculate the net pay

netPay = grossPay - fedTax - deduct;

// Displaying the result

outFile << \"Weekly Pay for: \" << setw(40) << name << endl;
outFile << \"Gross Pay: \" << setw(6) << grossPay << endl;
outFile << \"Hours Worked: \" << setw(6) << hoursWorked << endl;
outFile << \"Rate of Pay: \" << setw(6) << rateOfPay << endl;
outFile << \"Married: \" << setw(6) << married << endl;
outFile << \"Dependents: \" << setw(6) << dep << endl;
outFile << \"Deductions: \" << setw(6) << deduct << endl;
outFile << \"Health: \" << setw(6) << price << endl;
outFile << \"Federal Tax: \" << setw(6) << fedTax << endl;
outFile << \"Net Pay: \" << setw(6) << netPay << endl;

inFile.close();
outFile.close();
return 0;
}


Output will be present at C:\\payroll.dat and will be like:

Weekly pay for: Mihcael Kelley
Gross Pay: 400.00
Hours Worked: 40.00
Rate of Pay: 10.00
Married: Y
Dependents: 2
Deductions: 40.00
Health: 28.00
Federal Tax: 39.84
Net Pay: 360.16

C++ programming windows console application visual studioSolutionPlease find the below program which will help you to fetch the output as per your need: /******
C++ programming windows console application visual studioSolutionPlease find the below program which will help you to fetch the output as per your need: /******
C++ programming windows console application visual studioSolutionPlease find the below program which will help you to fetch the output as per your need: /******

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site