Note: Could you plz go this code and let me know if
u need any changes in this.Thank You
_________________
// PayrollIn.txt
1001 Joe 22 37.50
1001 Tom 36 55.750
1001 John 39 62.50
__________________
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
using namespace std;
void readFile(int ids[], string names[], int hoursWork[], double
payRate[], int cnt);
void calculateGrossNetPay(int* hoursWork, double* payRate, double*
grossPay, double* netpay, int cnt);
void displayReport(int* ids, string* names, int* hoursWork, double*
payRate, double* grossPay, double* netpay, int cnt);
int main()
{
int choice;
int cnt = 0;
int* ids;
string* names;
int* hoursWork;
double* payRate;
int flag = 0, flag2 = 0;
double* grossPay;
double* netpay;
//defines an input stream for the data file
ifstream dataIn;
while (true) {
cout << "\n\n::MENU::" << endl;
cout << "1.Read File" << endl;
cout << "2.Calculate Gross Pay and Net Pay" <<
endl;
cout << "3.Print output to File" << endl;
cout << "Enter Choice :";
cin >> choice;
switch (choice) {
case 1: {
int id, hw;
string name;
double pay;
dataIn.open("PayrollIn.txt");
//checking whether the file name is valid or not
if (dataIn.fail()) {
cout << "** File Not Found **";
exit(0);
}
else {
while (dataIn >> id >> name >> hw >> pay)
{
cnt++;
}
dataIn.close();
// Creating array dynamically
ids = new int[cnt];
names = new string[cnt];
hoursWork = new int[cnt];
payRate = new double[cnt];
readFile(ids, names, hoursWork, payRate, cnt);
flag = 1;
continue;
}
}
case 2: {
if (flag == 1) {
grossPay = new double[cnt];
netpay = new double[cnt];
calculateGrossNetPay(hoursWork, payRate, grossPay, netpay, cnt);
flag2 = 1;
}
else {
cout << "Please choose option#1" << endl;
continue;
}
continue;
}
case 3: {
if (flag == 1 && flag2 == 1) {
displayReport(ids, names, hoursWork, payRate, grossPay, netpay,
cnt);
}
else if (flag == 1 && flag2 != 1) {
cout << "Please choose option#1" << endl;
continue;
}
else if (flag != 1 && flag2 == 1) {
cout << "Please choose option#2" << endl;
continue;
}
break;
}
default: {
continue;
}
}
break;
}
return 0;
}
void readFile(int ids[], string names[], int hoursWork[], double
payRate[], int cnt)
{
//defines an input stream for the data file
ifstream dataIn;
int id, hw;
string name;
double pay;
dataIn.open("PayrollIn.txt");
for (int i = 0; i < cnt; i++) {
dataIn >> id >> name >> hw >> pay;
ids[i] = id;
names[i] = name;
hoursWork[i] = hw;
payRate[i] = pay;
}
dataIn.close();
cout << "Data Successfully read from file" <<
endl;
}
void calculateGrossNetPay(int* hoursWork, double* payRate, double*
grossPay, double* netpay, int cnt)
{
for (int i = 0; i < cnt; i++) {
grossPay[i] = hoursWork[i] * payRate[i];
netpay[i] = grossPay[i] - grossPay[i] * (11.5 / 100);
}
cout << "Successfully calculated gross pay and net pay"
<< endl;
}
void displayReport(int* ids, string* names, int* hoursWork, double*
payRate, double* grossPay, double* netpay, int cnt)
{
//Defines an output stream for the data file
ofstream dataOut;
dataOut.open("PayrollOut.txt");
for (int i = 0; i < cnt; i++) {
dataOut << ids[i] << "\t" << names[i] <<
"\t" << hoursWork[i] << "\t" << payRate[i]
<< "\t" << grossPay[i] << "\t" << netpay[i]
<< endl;
}
dataOut.close();
cout << "Data written to output file" << endl;
}
__________________________
Output:
________________________
outputfile:(PayrollOut.txt)
__________________Thank You
Exam 1 -Makeup Part B Exam 1 - Makeup Chapters 1 to 5-Part B Write a...
How would I do this problem? Write a C++ menu driven Payroll program. Must be user friendly. Menu 1. Check data file 2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, template, iterators and containers. The program to process an input file below to...
Write a C++ menu driven Payroll program. Must be user friendly. Menu 1. Check data file 2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, iterators and containers. The program to process an input file below to calculate tax of 28% and output it...
Test: Exam 1 - Chapters 1 -3 Tins Ramaning: 01 2Smt Tte his Question: 1 pt 13 of 14 (10 complete)This Test: 14 pts possible 4a Show Work Question Help Use the following cell phone airport data speeds (Mbps) from a particular network. Find Q3. 0.2 0.7 2.2 5.7 11.1 0.2 0.8 2.4 6.1 11.5 0.4 0.8 2.5 6.2 13.3 0.5 0.8 2.5 6.7 13.5 0.5 1.2 3.4 7.5 14.1 0.6 1.2 3.5 7.9 15.1 0.6 14 15 3.9 9.1...
java Part 1 Create a NetBeans project that asks for a file name. The file should contain an unknown quantity of double numeric values with each number on its own line. There should be no empty lines. Open the file and read the numbers. Print the sum, average, and the count of the numbers. Be sure to label the outputs very clearly. Read the file values as Strings and use Double.parseDouble() to convert them. Part 2 Create a NetBeans project...
Project 4 - Covers Chapters 1-5 The MS Society is raising money this year having an indoor "walk-a-thon" where participants enter the number of steps they walk each day for up to 30 days and translate those steps into distances as a way to raise money to help find a cure for multiple sclerosis. NOTE: YOU ARE NOT ASKING FOR THE TOTAL STEPS, THE USER IS ENTERING STEPS EVERY DAY. Create a program that asks for a user's full name,...
I need help completing all of part B please
Check mywrk Exercise 9-11A Calculating employee and employer payroll taxes LO 9-5 3.57 Sky Co. employed Tom Mills in Year 1. Tom earned $5,100 per month and worked the entire year. Assume the Social Security tax rate is 6 percent for the first $110,000 of earnings, and the Medicare tax rate is 1.5 percent. Tom's federal income tax withholding amount is $910 per month. Use 5.4 percent for the state unemployment...
Hello,
Similar questions like this have been previously answered, but
this question is different because it has only one part while
similar questions have 2 parts and their solutions is a combination
of the 2 parts. I have not been able to find an absolute solution
for this part.
QUESTION:
Modify your program from Learning Journal Unit 7 to read
dictionary items from a file and write the inverted dictionary to a
file. You will need to decide on the...
Two Part coding quesiton. Python only please
Part B:
The second task is to write that output to a file.
The steps are 1. Open a file for writing, e.g. outfile =
open(“output.txt”,”w”)
2. Whenever you print, include the argument file = outfile For
example, if you previously had print(x) you will now have print(x,
file = outfile)
3. Close the file, e.g. outfile.close()
a Amazon.com: Kuzy BLACI x ht Macbook Case I Glaze P x f Microsoft Word labo6.doc...
PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP)
Using a structured approach to writing the program: This section will guide you in starting the program in a methodical way. The program will display a window with GUI widgets that are associated with particular functions: Employee Payroll O X -- - - - - - - - - - - Show Payroll Find Employee by Name Highest Lowest Find Employee by Amount Write Output to Fie Cancel - -------- ------------- Notice that some of...