SlideShare a Scribd company logo
1 of 8
Download to read offline
I need help to modify my code according to the instructions:
Modify the program you created in Lab Assignment #9 (Babbage's Cabbage's, Part 3) to include
the following features:
Use parallel arrays to store the full name and gross pay of all employees entered. The size of the
arrays must be easy to change using a single symbolic constant. At the end of the program, after
all the individual employee records have been input and processed, write a summary table to the
report file listing the employees entered and their gross pay amounts. See the sample report that
follows for an example. (Your program may only store these two specific pieces of employee
data in arrays. You will not earn credit for this feature if you create additional arrays for other
pieces of employee data.)
Create individual functions for computing the sum of the gross pay amounts, the average, finding
the maximum gross pay, and the minimum gross pay. Each of these four functions can accept
only the array of gross pay amounts and number of valid data items as parameters, and cannot
depend on the array being arranged in order. Display the total, average, minimum, and maximum
of the gross pay amounts in the report file summary.
Use the optimized version of the Bubble Sort (v.3) so that the summary table of employee names
and gross pay amounts is arranged in descending order by gross pay.
Read input from a data file, rather than the user. See the sample data file that follows for an
example (note that the amount of the transportation deduction is supplied directly). You may
assume that all data provided in the file is valid. Remove all code related to keyboard input and
data validation so that the program simply reads from the data file and writes to the report file
without needing any input from the user.
Sample Report File
Submissions whose programs do not compile without errors, do not use a modular style (i.e., all
of the program code appears in the main module), or contain any of the items listed below, will
receive a grade of zero:
Global variables, Recursive module calls, vectors, structs, or classes, The line using namespace
std; Inclusion of libraries that have not been introduced as part of the class (including those that
are specific to a particular operating system), or use of their commands, Calls to the system
function
This is my code that needs to be modified:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <ostream>
#define min_hours 10.0
#define max_hours 55.0
#define min_hourly_rate 15.00
#define max_hourly_rate 65.00
#define overtime_limit 34.0
void input_employee_data(double &hours_worked, double &hourly_wage);
void calculate_gross_pay(double &hours_worked, double &hourly_wage, double& ovt_hours,
double& reg_hours, double &gross_pay);
void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes);
std::string input_full_name(std::string& first_name,
std::string& last_name);
std::string join_names(std::string first_name, std::string last_name, std::string& full_name);
void display_results(double gross_pay, double net_pay, double hourly_wage,
double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name);
std::string output_full_name(std::string full_name);
void show_header();
void additional_deduct(char& parking_garage, char& transit, char& bike, double &deduct);
char get_yes_no();
void output_results(std::ostream& stream, double gross_pay, double net_pay,
double hourly_wage, double deduct, double reg_hours,
double ovt_hours, double taxes, std::string full_name);
void output_results(std::ostream& stream, double gross_pay, double net_pay,
double hourly_wage, double deduct, double reg_hours,
double ovt_hours, double taxes, std::string full_name);
int main()
{
double hours_worked;
double hourly_wage;
double gross_pay;
double ovt_hours;
double reg_hours;
double deduct = 0;
double net_pay;
double taxes;
char process_another_employee;
char parking_garage;
char transit;
char bike;
std::string first_name;
std::string last_name;
std::string full_name;
std::ofstream outfile("C:/Temp/payroll.txt");
if (!outfile.is_open())
{
std::cout << "Unable to open a file!" << std::endl;
}
do
{
full_name = input_full_name(first_name, last_name);
input_employee_data(hours_worked, hourly_wage);
additional_deduct(parking_garage, transit, bike, deduct);
calculate_gross_pay(hours_worked, hourly_wage, ovt_hours, reg_hours, gross_pay);
calculate_net_pay(gross_pay, deduct, net_pay, taxes);
display_results(gross_pay, net_pay, hourly_wage, deduct, reg_hours, ovt_hours, taxes,
full_name);
process_another_employee = get_yes_no();
output_results(outfile, gross_pay, net_pay, hourly_wage, deduct,
reg_hours, ovt_hours, taxes, full_name);
} while (process_another_employee == 'Y' || process_another_employee == 'y');
if (process_another_employee == 'N' || process_another_employee == 'n') {
}
outfile.close();
}
std::string input_full_name(std::string& first_name, std::string& last_name)
{
std::string full_name;
std::cout << "Enter employee's first name: ";
std::cin >> first_name;
std::cout << "Enter employee's last name: ";
std::cin >> last_name;
join_names(first_name, last_name, full_name);
return full_name;
}
std::string join_names(std::string first_name, std::string last_name,
std::string& full_name)
{
std::string join_names;
full_name = last_name + ", " + first_name;
return join_names;
}
std::string output_full_name(std::string full_name)
{
std::string output_full_name;
std::cout << full_name;
return output_full_name;
}
void input_employee_data(double &hours_worked, double &hourly_wage)
{
std::cout << "Enter number of hours worked: ";
std::cin >> hours_worked;
while (hours_worked < min_hours || hours_worked > max_hours) {
std::cout << "The number of hours worked must be between " << min_hours << " and " <<
max_hours << " " << std::endl;
std::cout << "Enter number of hours worked: ";
std::cin >> hours_worked;
}
std::cout << "Enter hourly pay rate: ";
std::cin >> hourly_wage;
while (hourly_wage < min_hourly_rate || hourly_wage > max_hourly_rate) {
std::cout << "The hourly pay rate must be between " << min_hourly_rate << " and " <<
max_hourly_rate << " " << std::endl;
std::cout << "Enter hourly pay rate: ";
std::cin >> hourly_wage;
}
}
void additional_deduct(char& parking_garage, char& transit, char& bike, double &deduct)
{
std::cout << "Does the employee use the parking gargage? (Y/N):";
std::cin >> parking_garage;
while (parking_garage != 'Y' && parking_garage != 'y' &&
parking_garage != 'N' && parking_garage != 'n') {
std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl;
std::cin >> parking_garage;
}
if (parking_garage == 'Y' || parking_garage == 'y') {
deduct += 7.50;
}
else {
std::cout << "Does employee participate in the transit program? (Y/N):";
std::cin >> transit;
while (transit != 'Y' && transit != 'y' && transit != 'N' && transit != 'n') {
std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl;
std::cin >> transit;
}
if (transit == 'y' || transit == 'Y') {
deduct + 5.0;
}
else {
std::cout << "Does employee rent a bike locker? (Y/N): " << std::endl;
std::cin >> bike;
}
while (bike != 'Y' && bike != 'y' && bike != 'N' && bike != 'n') {
std::cout << "Pleae type 'Y' for yes or 'N' for no" << std::endl;
std::cin >> bike;
}
if (bike == 'Y' || bike == 'y') {
deduct += 1;
}
}
}
void calculate_gross_pay(double &hours_worked, double &hourly_wage, double &ovt_hours,
double &reg_hours, double &gross_pay)
{
if (hours_worked <= overtime_limit) {
reg_hours = hours_worked;
ovt_hours = 0;
}
else {
reg_hours = overtime_limit;
ovt_hours = hours_worked - overtime_limit;
}
gross_pay = (reg_hours * hourly_wage) + (ovt_hours * (hourly_wage * 1.5));
}
void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes)
{
taxes = gross_pay * 0.205;
net_pay = gross_pay - taxes - deduct;
}
void show_header()
{
std::cout << std::fixed << std::setprecision(2) << std::left;
std::cout << std::setw(20) << "Name";
std::cout << std::setw(7) << "Reg";
std::cout << std::setw(7) << "Ovt";
std::cout << std::setw(9) << "Hourly";
std::cout << std::setw(8) << "Gross";
std::cout << std::setw(8) << "Taxes";
std::cout << std::setw(8) << "Deduct";
std::cout << std::setw(7) << "Net" << std::endl;
std::cout << std::setw(20) << std::left << " ";
std::cout << std::setw(7) << "Hours";
std::cout << std::setw(7) << "Hours";
std::cout << std::setw(9) << "Rate";
std::cout << std::setw(24) << "Pay";
std::cout << std::setw(16) << "Pay" << std::endl;
std::cout << "================== ===== ===== ======= ====== ====== "
"====== =====" << std::endl;
}
void display_results(double gross_pay, double net_pay,
double hourly_wage, double deduct, double reg_hours, double ovt_hours,
double taxes, std::string full_name)
{
show_header();
std::cout << std::fixed << std::setprecision(2) << std::endl << std::left;
std::cout << std::setw(20) << full_name;
std::cout << std::setw(5) << reg_hours;
std::cout << std::setw(7) << ovt_hours;
std::cout << std::setw(9) << hourly_wage;
std::cout << std::setw(8) << gross_pay;
std::cout << std::setw(8) << taxes << " ";
std::cout << std::setw(8) << deduct;
std::cout << std::setw(7) << net_pay << std::endl;
}
char get_yes_no()
{
char process_another_employee;
std::ofstream outfile;
std::cout << std::endl;
std::cout << "Do you want to process another employee (Y/N)? ";
std::cin >> process_another_employee;
if (process_another_employee != 'Y' && process_another_employee != 'y'
&& process_another_employee != 'N' && process_another_employee != 'n') {
std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl;
return get_yes_no();
}
else return process_another_employee;
}
void output_results(std::ostream& stream, double gross_pay, double net_pay,
double hourly_wage, double deduct, double reg_hours,
double ovt_hours, double taxes, std::string full_name)
{
stream << std::fixed << std::setprecision(2) << std::left
<< std::setw(20) << "Name"
<< std::setw(7) << "Reg"
<< std::setw(7) << "Ovt"
<< std::setw(9) << "Hourly"
<< std::setw(8) << "Gross"
<< std::setw(8) << "Taxes"
<< std::setw(8) << "Deduct"
<< std::setw(7) << "Net" << std::endl
<< std::setw(20) << std::left << " "
<< std::setw(7) << "Hours"
<< std::setw(7) << "Hours"
<< std::setw(9) << "Rate"
<< std::setw(24) << "Pay"
<< std::setw(16) << "Pay" << std::endl
<< "================== ===== ===== ======= ====== ====== "
"====== =====" << std::endl
<< std::setw(20) << full_name
<< std::setw(5) << reg_hours
<< std::setw(9) << ovt_hours
<< std::setw(9) << hourly_wage
<< std::setw(6) << gross_pay
<< std::setw(8) << taxes << " "
<< std::setw(8) << deduct
<< std::setw(6) << net_pay << std::endl
<< std::endl;
}
Data file:

More Related Content

Similar to I need help to modify my code according to the instructions- Modify th.pdf

12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfssuser6254411
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfmallik3000
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment systempranoy_seenu
 

Similar to I need help to modify my code according to the instructions- Modify th.pdf (20)

C++ functions
C++ functionsC++ functions
C++ functions
 
C++ functions
C++ functionsC++ functions
C++ functions
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Tt subtemplates-caching
Tt subtemplates-cachingTt subtemplates-caching
Tt subtemplates-caching
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdfProgramming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
Programming For Big Data [ Submission DvcScheduleV2.cpp and StaticA.pdf
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 

More from pnaran46

John works as a goldsmith who often repairs jewellry- Maria brought in.pdf
John works as a goldsmith who often repairs jewellry- Maria brought in.pdfJohn works as a goldsmith who often repairs jewellry- Maria brought in.pdf
John works as a goldsmith who often repairs jewellry- Maria brought in.pdfpnaran46
 
L-{anbmcmdnn-m0} (1).pdf
L-{anbmcmdnn-m0} (1).pdfL-{anbmcmdnn-m0} (1).pdf
L-{anbmcmdnn-m0} (1).pdfpnaran46
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfpnaran46
 
Given that x has a Poitson destribition with -1-7- what is the poobati.pdf
Given that x has a Poitson destribition with -1-7- what is the poobati.pdfGiven that x has a Poitson destribition with -1-7- what is the poobati.pdf
Given that x has a Poitson destribition with -1-7- what is the poobati.pdfpnaran46
 
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdf
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdfFind the p-value using Excel (not Appendix D)- (Round your answers to.pdf
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdfpnaran46
 
Apple Inc- had gone through a hard period in the early 90s and almost.pdf
Apple Inc- had gone through a hard period in the early 90s and almost.pdfApple Inc- had gone through a hard period in the early 90s and almost.pdf
Apple Inc- had gone through a hard period in the early 90s and almost.pdfpnaran46
 
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdfpnaran46
 
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdf
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdfa- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdf
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdfpnaran46
 
57) All of the following are non-arguments except- a- Americans are ma.pdf
57) All of the following are non-arguments except- a- Americans are ma.pdf57) All of the following are non-arguments except- a- Americans are ma.pdf
57) All of the following are non-arguments except- a- Americans are ma.pdfpnaran46
 
2- An instructor wishes to see whether the variation in scores of the.pdf
2- An instructor wishes to see whether the variation in scores of the.pdf2- An instructor wishes to see whether the variation in scores of the.pdf
2- An instructor wishes to see whether the variation in scores of the.pdfpnaran46
 
You are working as the chief economist for the Ministry of Economy in.pdf
You are working as the chief economist for the Ministry of Economy in.pdfYou are working as the chief economist for the Ministry of Economy in.pdf
You are working as the chief economist for the Ministry of Economy in.pdfpnaran46
 
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdf
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdfThe Taylors agreed to make monthly payments on a mortgage of $130-000.pdf
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdfpnaran46
 
The supply of low-skilled workers in China is perfectly elastic- In 20.pdf
The supply of low-skilled workers in China is perfectly elastic- In 20.pdfThe supply of low-skilled workers in China is perfectly elastic- In 20.pdf
The supply of low-skilled workers in China is perfectly elastic- In 20.pdfpnaran46
 
The Federal Reserve provides accounts to financial institutions only f.pdf
The Federal Reserve provides accounts to financial institutions only f.pdfThe Federal Reserve provides accounts to financial institutions only f.pdf
The Federal Reserve provides accounts to financial institutions only f.pdfpnaran46
 
The following is the balance sheet numbers (in millions) reported by B.pdf
The following is the balance sheet numbers (in millions) reported by B.pdfThe following is the balance sheet numbers (in millions) reported by B.pdf
The following is the balance sheet numbers (in millions) reported by B.pdfpnaran46
 
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdfpnaran46
 
Singh Company reports a contribution margin of $717-000 and fixed cost.pdf
Singh Company reports a contribution margin of $717-000 and fixed cost.pdfSingh Company reports a contribution margin of $717-000 and fixed cost.pdf
Singh Company reports a contribution margin of $717-000 and fixed cost.pdfpnaran46
 
Provide an appropriate response- How many ways can five people- A- B-.pdf
Provide an appropriate response- How many ways can five people- A- B-.pdfProvide an appropriate response- How many ways can five people- A- B-.pdf
Provide an appropriate response- How many ways can five people- A- B-.pdfpnaran46
 
QRT Soltware creates and distributes inventory control noftware- The h.pdf
QRT Soltware creates and distributes inventory control noftware- The h.pdfQRT Soltware creates and distributes inventory control noftware- The h.pdf
QRT Soltware creates and distributes inventory control noftware- The h.pdfpnaran46
 

More from pnaran46 (19)

John works as a goldsmith who often repairs jewellry- Maria brought in.pdf
John works as a goldsmith who often repairs jewellry- Maria brought in.pdfJohn works as a goldsmith who often repairs jewellry- Maria brought in.pdf
John works as a goldsmith who often repairs jewellry- Maria brought in.pdf
 
L-{anbmcmdnn-m0} (1).pdf
L-{anbmcmdnn-m0} (1).pdfL-{anbmcmdnn-m0} (1).pdf
L-{anbmcmdnn-m0} (1).pdf
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
 
Given that x has a Poitson destribition with -1-7- what is the poobati.pdf
Given that x has a Poitson destribition with -1-7- what is the poobati.pdfGiven that x has a Poitson destribition with -1-7- what is the poobati.pdf
Given that x has a Poitson destribition with -1-7- what is the poobati.pdf
 
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdf
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdfFind the p-value using Excel (not Appendix D)- (Round your answers to.pdf
Find the p-value using Excel (not Appendix D)- (Round your answers to.pdf
 
Apple Inc- had gone through a hard period in the early 90s and almost.pdf
Apple Inc- had gone through a hard period in the early 90s and almost.pdfApple Inc- had gone through a hard period in the early 90s and almost.pdf
Apple Inc- had gone through a hard period in the early 90s and almost.pdf
 
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf
6) Cytological mapping (4 points) i) Deletional-deficiency-ii) Duplica.pdf
 
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdf
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdfa- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdf
a- Let- a host with IP address 10-0-0-10-3550 want to transmit 16 bit.pdf
 
57) All of the following are non-arguments except- a- Americans are ma.pdf
57) All of the following are non-arguments except- a- Americans are ma.pdf57) All of the following are non-arguments except- a- Americans are ma.pdf
57) All of the following are non-arguments except- a- Americans are ma.pdf
 
2- An instructor wishes to see whether the variation in scores of the.pdf
2- An instructor wishes to see whether the variation in scores of the.pdf2- An instructor wishes to see whether the variation in scores of the.pdf
2- An instructor wishes to see whether the variation in scores of the.pdf
 
You are working as the chief economist for the Ministry of Economy in.pdf
You are working as the chief economist for the Ministry of Economy in.pdfYou are working as the chief economist for the Ministry of Economy in.pdf
You are working as the chief economist for the Ministry of Economy in.pdf
 
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdf
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdfThe Taylors agreed to make monthly payments on a mortgage of $130-000.pdf
The Taylors agreed to make monthly payments on a mortgage of $130-000.pdf
 
The supply of low-skilled workers in China is perfectly elastic- In 20.pdf
The supply of low-skilled workers in China is perfectly elastic- In 20.pdfThe supply of low-skilled workers in China is perfectly elastic- In 20.pdf
The supply of low-skilled workers in China is perfectly elastic- In 20.pdf
 
The Federal Reserve provides accounts to financial institutions only f.pdf
The Federal Reserve provides accounts to financial institutions only f.pdfThe Federal Reserve provides accounts to financial institutions only f.pdf
The Federal Reserve provides accounts to financial institutions only f.pdf
 
The following is the balance sheet numbers (in millions) reported by B.pdf
The following is the balance sheet numbers (in millions) reported by B.pdfThe following is the balance sheet numbers (in millions) reported by B.pdf
The following is the balance sheet numbers (in millions) reported by B.pdf
 
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf
1) Ludwig von Mises (1871 - 1973) was an influential economist from Au.pdf
 
Singh Company reports a contribution margin of $717-000 and fixed cost.pdf
Singh Company reports a contribution margin of $717-000 and fixed cost.pdfSingh Company reports a contribution margin of $717-000 and fixed cost.pdf
Singh Company reports a contribution margin of $717-000 and fixed cost.pdf
 
Provide an appropriate response- How many ways can five people- A- B-.pdf
Provide an appropriate response- How many ways can five people- A- B-.pdfProvide an appropriate response- How many ways can five people- A- B-.pdf
Provide an appropriate response- How many ways can five people- A- B-.pdf
 
QRT Soltware creates and distributes inventory control noftware- The h.pdf
QRT Soltware creates and distributes inventory control noftware- The h.pdfQRT Soltware creates and distributes inventory control noftware- The h.pdf
QRT Soltware creates and distributes inventory control noftware- The h.pdf
 

Recently uploaded

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

I need help to modify my code according to the instructions- Modify th.pdf

  • 1. I need help to modify my code according to the instructions: Modify the program you created in Lab Assignment #9 (Babbage's Cabbage's, Part 3) to include the following features: Use parallel arrays to store the full name and gross pay of all employees entered. The size of the arrays must be easy to change using a single symbolic constant. At the end of the program, after all the individual employee records have been input and processed, write a summary table to the report file listing the employees entered and their gross pay amounts. See the sample report that follows for an example. (Your program may only store these two specific pieces of employee data in arrays. You will not earn credit for this feature if you create additional arrays for other pieces of employee data.) Create individual functions for computing the sum of the gross pay amounts, the average, finding the maximum gross pay, and the minimum gross pay. Each of these four functions can accept only the array of gross pay amounts and number of valid data items as parameters, and cannot depend on the array being arranged in order. Display the total, average, minimum, and maximum of the gross pay amounts in the report file summary. Use the optimized version of the Bubble Sort (v.3) so that the summary table of employee names and gross pay amounts is arranged in descending order by gross pay. Read input from a data file, rather than the user. See the sample data file that follows for an example (note that the amount of the transportation deduction is supplied directly). You may assume that all data provided in the file is valid. Remove all code related to keyboard input and data validation so that the program simply reads from the data file and writes to the report file without needing any input from the user. Sample Report File Submissions whose programs do not compile without errors, do not use a modular style (i.e., all of the program code appears in the main module), or contain any of the items listed below, will receive a grade of zero: Global variables, Recursive module calls, vectors, structs, or classes, The line using namespace std; Inclusion of libraries that have not been introduced as part of the class (including those that are specific to a particular operating system), or use of their commands, Calls to the system function This is my code that needs to be modified: #include <iostream> #include <iomanip> #include <string> #include <fstream> #include <ostream>
  • 2. #define min_hours 10.0 #define max_hours 55.0 #define min_hourly_rate 15.00 #define max_hourly_rate 65.00 #define overtime_limit 34.0 void input_employee_data(double &hours_worked, double &hourly_wage); void calculate_gross_pay(double &hours_worked, double &hourly_wage, double& ovt_hours, double& reg_hours, double &gross_pay); void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes); std::string input_full_name(std::string& first_name, std::string& last_name); std::string join_names(std::string first_name, std::string last_name, std::string& full_name); void display_results(double gross_pay, double net_pay, double hourly_wage, double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name); std::string output_full_name(std::string full_name); void show_header(); void additional_deduct(char& parking_garage, char& transit, char& bike, double &deduct); char get_yes_no(); void output_results(std::ostream& stream, double gross_pay, double net_pay, double hourly_wage, double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name); void output_results(std::ostream& stream, double gross_pay, double net_pay, double hourly_wage, double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name); int main() { double hours_worked; double hourly_wage; double gross_pay; double ovt_hours; double reg_hours; double deduct = 0; double net_pay; double taxes; char process_another_employee; char parking_garage; char transit; char bike; std::string first_name; std::string last_name; std::string full_name; std::ofstream outfile("C:/Temp/payroll.txt");
  • 3. if (!outfile.is_open()) { std::cout << "Unable to open a file!" << std::endl; } do { full_name = input_full_name(first_name, last_name); input_employee_data(hours_worked, hourly_wage); additional_deduct(parking_garage, transit, bike, deduct); calculate_gross_pay(hours_worked, hourly_wage, ovt_hours, reg_hours, gross_pay); calculate_net_pay(gross_pay, deduct, net_pay, taxes); display_results(gross_pay, net_pay, hourly_wage, deduct, reg_hours, ovt_hours, taxes, full_name); process_another_employee = get_yes_no(); output_results(outfile, gross_pay, net_pay, hourly_wage, deduct, reg_hours, ovt_hours, taxes, full_name); } while (process_another_employee == 'Y' || process_another_employee == 'y'); if (process_another_employee == 'N' || process_another_employee == 'n') { } outfile.close(); } std::string input_full_name(std::string& first_name, std::string& last_name) { std::string full_name; std::cout << "Enter employee's first name: "; std::cin >> first_name; std::cout << "Enter employee's last name: "; std::cin >> last_name; join_names(first_name, last_name, full_name); return full_name; } std::string join_names(std::string first_name, std::string last_name, std::string& full_name) { std::string join_names; full_name = last_name + ", " + first_name; return join_names; }
  • 4. std::string output_full_name(std::string full_name) { std::string output_full_name; std::cout << full_name; return output_full_name; } void input_employee_data(double &hours_worked, double &hourly_wage) { std::cout << "Enter number of hours worked: "; std::cin >> hours_worked; while (hours_worked < min_hours || hours_worked > max_hours) { std::cout << "The number of hours worked must be between " << min_hours << " and " << max_hours << " " << std::endl; std::cout << "Enter number of hours worked: "; std::cin >> hours_worked; } std::cout << "Enter hourly pay rate: "; std::cin >> hourly_wage; while (hourly_wage < min_hourly_rate || hourly_wage > max_hourly_rate) { std::cout << "The hourly pay rate must be between " << min_hourly_rate << " and " << max_hourly_rate << " " << std::endl; std::cout << "Enter hourly pay rate: "; std::cin >> hourly_wage; } } void additional_deduct(char& parking_garage, char& transit, char& bike, double &deduct) { std::cout << "Does the employee use the parking gargage? (Y/N):"; std::cin >> parking_garage; while (parking_garage != 'Y' && parking_garage != 'y' && parking_garage != 'N' && parking_garage != 'n') { std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl; std::cin >> parking_garage; } if (parking_garage == 'Y' || parking_garage == 'y') { deduct += 7.50; }
  • 5. else { std::cout << "Does employee participate in the transit program? (Y/N):"; std::cin >> transit; while (transit != 'Y' && transit != 'y' && transit != 'N' && transit != 'n') { std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl; std::cin >> transit; } if (transit == 'y' || transit == 'Y') { deduct + 5.0; } else { std::cout << "Does employee rent a bike locker? (Y/N): " << std::endl; std::cin >> bike; } while (bike != 'Y' && bike != 'y' && bike != 'N' && bike != 'n') { std::cout << "Pleae type 'Y' for yes or 'N' for no" << std::endl; std::cin >> bike; } if (bike == 'Y' || bike == 'y') { deduct += 1; } } } void calculate_gross_pay(double &hours_worked, double &hourly_wage, double &ovt_hours, double &reg_hours, double &gross_pay) { if (hours_worked <= overtime_limit) { reg_hours = hours_worked; ovt_hours = 0; } else { reg_hours = overtime_limit; ovt_hours = hours_worked - overtime_limit; } gross_pay = (reg_hours * hourly_wage) + (ovt_hours * (hourly_wage * 1.5)); } void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes) {
  • 6. taxes = gross_pay * 0.205; net_pay = gross_pay - taxes - deduct; } void show_header() { std::cout << std::fixed << std::setprecision(2) << std::left; std::cout << std::setw(20) << "Name"; std::cout << std::setw(7) << "Reg"; std::cout << std::setw(7) << "Ovt"; std::cout << std::setw(9) << "Hourly"; std::cout << std::setw(8) << "Gross"; std::cout << std::setw(8) << "Taxes"; std::cout << std::setw(8) << "Deduct"; std::cout << std::setw(7) << "Net" << std::endl; std::cout << std::setw(20) << std::left << " "; std::cout << std::setw(7) << "Hours"; std::cout << std::setw(7) << "Hours"; std::cout << std::setw(9) << "Rate"; std::cout << std::setw(24) << "Pay"; std::cout << std::setw(16) << "Pay" << std::endl; std::cout << "================== ===== ===== ======= ====== ====== " "====== =====" << std::endl; } void display_results(double gross_pay, double net_pay, double hourly_wage, double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name) { show_header(); std::cout << std::fixed << std::setprecision(2) << std::endl << std::left; std::cout << std::setw(20) << full_name; std::cout << std::setw(5) << reg_hours; std::cout << std::setw(7) << ovt_hours; std::cout << std::setw(9) << hourly_wage; std::cout << std::setw(8) << gross_pay; std::cout << std::setw(8) << taxes << " "; std::cout << std::setw(8) << deduct; std::cout << std::setw(7) << net_pay << std::endl; }
  • 7. char get_yes_no() { char process_another_employee; std::ofstream outfile; std::cout << std::endl; std::cout << "Do you want to process another employee (Y/N)? "; std::cin >> process_another_employee; if (process_another_employee != 'Y' && process_another_employee != 'y' && process_another_employee != 'N' && process_another_employee != 'n') { std::cout << "Please type 'Y' for yes or 'N' for no" << std::endl; return get_yes_no(); } else return process_another_employee; } void output_results(std::ostream& stream, double gross_pay, double net_pay, double hourly_wage, double deduct, double reg_hours, double ovt_hours, double taxes, std::string full_name) { stream << std::fixed << std::setprecision(2) << std::left << std::setw(20) << "Name" << std::setw(7) << "Reg" << std::setw(7) << "Ovt" << std::setw(9) << "Hourly" << std::setw(8) << "Gross" << std::setw(8) << "Taxes" << std::setw(8) << "Deduct" << std::setw(7) << "Net" << std::endl << std::setw(20) << std::left << " " << std::setw(7) << "Hours" << std::setw(7) << "Hours" << std::setw(9) << "Rate" << std::setw(24) << "Pay" << std::setw(16) << "Pay" << std::endl << "================== ===== ===== ======= ====== ====== " "====== =====" << std::endl << std::setw(20) << full_name << std::setw(5) << reg_hours << std::setw(9) << ovt_hours << std::setw(9) << hourly_wage << std::setw(6) << gross_pay << std::setw(8) << taxes << " " << std::setw(8) << deduct << std::setw(6) << net_pay << std::endl