This is C++. The task is to convert the program to make use of fucntions, but I am am struggling to figure out how to do so.
#include <iostream>
#include <iomanip>
using namespace std;
main(){
char empid[ 100 ][ 12 ];
char fname[ 100 ][ 14 ], lastname[ 100 ][ 15 ];
int hw[ 100 ];
double gp[ 100 ], np[ 100 ], hr[ 100 ], taxrate[100], taxamt[ 100
];
int counter = 0;
int i;
cout<<"ENTER EMP ID, FNAME, LNAME, HRS WORKED, HRLY RATE ctrl
z to end"<<endl;
while(
cin>>empid[counter]>>fname[counter]>>lastname[counter]>>hw[counter]>>
hr[counter])
counter=counter+1;
for ( i=0; i<counter; i++){
gp[i] = hw[i] * hr[i];}//end grosspay for loop
for (i=0; i<counter; i++){
if (gp[i]>500) taxrate[i] = .30;
else if (gp[i]>200) taxrate[i]=.20;
else taxrate[i] = .10;
}// FOR
for ( i=0; i<counter; i++){
taxamt[i] = gp[i] * taxrate[i];}//end taxamount for loop
for ( i=0; i<counter; i++){
np[i] = gp[i] - taxamt[i];}//end netpay for loop
cout<<endl;
cout<<setw(14)<<"EMPLOYEE
ID"<<setw(16)<<"FIRST NAME"<<setw(17)
<<"LAST NAME"
<<setw(4)<<"HW"<<setw(5)<<"HR"<<setw(6)
<<"GROSS"<<setw(6)<<"TAX"<<setw(9)<<"NET
PAY"<<endl<<endl;
for (i=0; i<counter;
i++){
cout<<setw(14)<<empid[i]<<setw(16)<<fname[i]<<setw(17)<<lastname[i]<<setw(4)
<<hw[i]<<setw(5)<<hr[i]<<setw(6)<<gp[i]<<setw(6)<<taxamt[i]<<setw(9)<<np[i]<<endl;
}// FOR
return 0;
}//MAIN
#include <iostream>
#include <iomanip>
using namespace std;
struct Employee {
char empid[12];
char fname[14];
char lastname[15];
int hw;
double gp, np, hr, taxrate, taxamt;
};
int readEmployees(Employee *emps) {
int counter = 0;
cout << "ENTER EMP ID, FNAME, LNAME,
HRS WORKED, HRLY RATE ctrl z to end" << endl;
while( cin >> emps[counter].empid
>> emps[counter].fname >> emps[counter].lastname
>> emps[counter].hw >> emps[counter].hr)
counter=counter+1;
return counter;
}
void calculateValues(Employee *emps, int counter) {
for (int i=0; i<counter; i++){
emps[i].gp =
emps[i].hw * emps[i].hr;
if (emps[i].gp >
500) emps[i].taxrate = .30;
else if (emps[i].gp
> 200) emps[i].taxrate=.20;
else
emps[i].taxrate = .10;
emps[i].taxamt =
emps[i].gp * emps[i].taxrate;
emps[i].np =
emps[i].gp - emps[i].taxamt;
}
}
void printDetails(Employee *emps, int counter) {
cout<<endl;
cout<<setw(14)<<"EMPLOYEE
ID"<<setw(16)<<"FIRST NAME"<<setw(17)
<<"LAST NAME"
<<setw(4)<<"HW"<<setw(5)<<"HR"<<setw(6)
<<"GROSS"<<setw(6)<<"TAX"<<setw(9)<<"NET
PAY"<<endl<<endl;
for (int i=0; i<counter; i++){
cout<<setw(14)<<emps[i].empid<<setw(16)<<emps[i].fname<<setw(17)<<emps[i].lastname<<setw(4)
<<emps[i].hw<<setw(5)<<emps[i].hr<<setw(6)<<emps[i].gp<<setw(6)<<emps[i].taxamt<<setw(9)<<emps[i].np<<endl;
}
}
int main(){
Employee employees[100];
int counter =
readEmployees(employees);
calculateValues(employees, counter);
printDetails(employees, counter);
return 0;
}//MAIN
**************************************************
Thanks for your question. We try our best to help you with detailed
answers, But in any case, if you need any modification or have a
query/issue with respect to above answer, Please ask that in the
comment section. We will surely try to address your query ASAP and
resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.
This is C++. The task is to convert the program to make use of fucntions, but...
Hello, I am trying to get this Array to show the summary of NETPAY but have been failing. What is wrong? #include <iostream> #include <iomanip> using namespace std; main(){ char empid[ 100 ][ 12 ]; char fname[ 100 ][ 14 ], lastname[ 100 ][ 15 ]; int sum; int hw[ 100 ]; double gp[ 100 ], np[ 100 ], hr[ 100 ], taxrate[100], taxamt[ 100 ]; int counter = 0; int i; cout<<"ENTER EMP ID, FNAME, LNAME, HRS...
Expand the payroll program to combine two sorting techniques
(Selection and Exchange sorts) for better efficiency in sorting the
employee’s net pay.
//I need to use an EXSEL sort in order to
combine the selection and Exchange sorts for my program. I
currently have a selection sort in there. Please help me with
replacing this with the EXSEL sort.
//My input files:
//My current code with the sel sort. Please help me replace this
with an EXSEL sort.
#include <fstream>...
Hello I need a small fix in my program. I need to display the youngest student and the average age of all of the students. It is not working Thanks. #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <algorithm> using namespace std; struct Student { string firstName; char middleName; string lastName; char collegeCode; int locCode; int seqCode; int age; }; struct sort_by_age { inline bool operator() (const Student& s1, const Student& s2) { return (s1.age < s2.age); // sort...
Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters student first name, 10 characters middle name, 20 characters last name, 9 characters student ID, 3 characters age, in years (3 digits) 2- Open the input file. Check for successful open. If the open failed, display an error message and return with value 1. 3- Use a pointer array to manage all the created student variables.Assume that there will not be more than 99...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Hi, I am trying to convert a string vector to a double vector in c++ , but for some reason I am getting this error message. Hope you can help! Thanks error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘const char*’ for argument ‘1’ to ‘double atof(const char*)’ double salary = atof(info[x].stringsalary); my code is... void display(vector<Employee_Data>& info){ double total = 0; cout << "id" <<setw(25) <<"first name" <<setw(25) <<"last name" <<setw(25) <<"gender" <<setw(25) <<"department" <<setw(25) <<"salary" << endl ; for(int...
How can I make this compatible with older C++ compilers that DO NOT make use of stoi and to_string? //Booking system #include <iostream> #include <iomanip> #include <string> using namespace std; string welcome(); void print_seats(string flight[]); void populate_seats(); bool validate_flight(string a); bool validate_seat(string a, int b); bool validate_book(string a); void print_ticket(string passenger[], int i); string flights [5][52]; string passengers [4][250]; int main(){ string seat, flight, book = "y"; int int_flight, p = 0, j = 0; int seat_number,...
I am trying to modify this program so that it stores the employee's name in a c-string and can handle up to 100 employees (so it would mostly be a partially filled array), but I cannot get it to work. It works with two files that it is suppose to read input from. Then it prints output to an output file. Employee Info File (first file read, M/F should be ignored): 5 Christine Kim 30.00 2 1 F 15 Ray...
Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found; string document[1000][6]; ifstream infile; char s[1000];...
This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...