Question

Hello, I am trying to get this Array to show the summary of NETPAY but have...

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 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

If you press Ctrl+z, the program will suspended, Ctrl+d, the program will be execute perfect...

Code:

#include <iostream>

#include <iomanip>

using namespace std;

int 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 WORKED, HRLY RATE ctrl d 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

Add a comment
Know the answer?
Add Answer to:
Hello, I am trying to get this Array to show the summary of NETPAY but have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is C++. The task is to convert the program to make use of fucntions, but...

    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,...

  • Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency...

    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...

    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...

    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 t...

    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);...

  • Hello, I am working on a project for my C++ class, I have the vast majority...

    Hello, I am working on a project for my C++ class, I have the vast majority of the code figured out but am running into a few issues. Mainly updating each * to an X. The problem is as follows:(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business...

  • Hello, I am working on my final and I am stuck right near the end of...

    Hello, I am working on my final and I am stuck right near the end of the the program. I am making a Tic-Tac-Toe game and I can't seem to figure out how to make the program ask if you would like to play again, and keep the same names for the players that just played, keep track of the player that wins, and display the number of wins said player has, after accepting to keep playing. I am wanting...

  • Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string>...

    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];...

  • I want to change this code and need help. I want the code to not use...

    I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...

  • Hey, so i am trying to have my program read a text file using a structure...

    Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT