Question

(Dont use array) OBJECT:To compute the payroll in a company of 10 employees, given an employees id number pay rate, number

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

#include<iostream>
#include<sstream>
using namespace std;

//method to get employee record from user
void get_emp_rec(int &id,double &prate,double &hours){
   string line;
   cout<<"Enter employee id: ";
   getline(cin,line);
   stringstream s(line);
   s>>id;
  
   cout<<"Enter pay rate: ";
   getline(cin,line);
   stringstream s1(line);
   s1>>prate;
  
   cout<<"Enter number of hours: ";
   getline(cin,line);
   stringstream s3(line);
   s3>>hours;
}
//method to compute gross pay
double compute_gpay(double hours,double prate){
   return (hours*prate);
}
//method to compute taxes
double compute_taxes(double gpay){
   double value=0;
   if(gpay<1000){
       value=0.05*gpay;
   }else if(gpay>1000 && gpay<1500){
       value=0.06*gpay;
   }else{
       value=0.07*gpay;
   }
   return value;
}
//method to compute net pay
double compute_npay(double gpay){
   double tax=compute_taxes(gpay);
   return (gpay-tax);
}
//main method
int main(){
   string output="";
   int id;
   double prate,hours,gpay=0,npay=0,totalgpay=0,totalnpay=0;
   for(int i=0;i<10;i++){
       get_emp_rec(id,prate,hours);
       gpay=compute_gpay(hours,prate);
       npay=compute_npay(gpay);
      
       ostringstream str1,str2,str3;
       str1<<id;
       str2<<gpay;
       str3<<npay;
      
       output+=str1.str()+"               "+str2.str()+"         "+str3.str()+"\n";
       totalgpay+=gpay;
       totalnpay+=npay;
      
   }
   cout<<"\nEmployee ID     Gross Pay      Net Pay";
   cout<<"\n-----------     ---------      -------\n";
   cout<<output<<"\n";
   cout<<"Total Gross Pay for company: "<<totalgpay<<"\n";
   cout<<"Total Net Pay for company : "<<totalnpay<<"\n";
  
   return 0;
}

//######################################################################

OUTPUT
########

CAUsersVijinAMDocuments\DevC++_Workspace\EmployeePay.exe Enter employee id: 234 Enter pay rate: 700 Enter number of hours: 1

Add a comment
Know the answer?
Add Answer to:
c++ (Don't use array) OBJECT:To compute the payroll in a company of 10 employees, given an...
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
  • Design a Payroll class with the following fields:

    IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...

  • Given attached you will find a file from Programming Challenge 5 of chapter 6 with required...

    Given attached you will find a file from Programming Challenge 5 of chapter 6 with required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: An empty string is given for the employee’s name. An invalid value is given to the employee’s ID number. If you implemented this field as a string, then an empty string could be invalid. If you implemented this field as a numeric variable, then a...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • The Excel file Payroll Data provides hourly salaries for a group of employees. Create an Excel...

    The Excel file Payroll Data provides hourly salaries for a group of employees. Create an Excel template that allows the user to select an employee by employee ID, enter the number of regular hours and overtime hours worked, and display a payroll summary with the employee name, gross pay, federal tax, state tax, Social Security, Medicare withholding deductions, and net pay. Assume that the federal tax rate is 11%, the state tax rate is 2.385%, Social Security withholding is 6.2%,...

  • Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,910 per week $36 per hour $46 per hour Overtime earnings rate Not applicable 1.5 times hourly rate 2 times hourly rate Number of withholding allowances 3 2 1 For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income...

  • Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate Overtime earnings rate $3,110 per week Not applicable $28 per hour 1.5 times hourly rate $48 per hour 2 times hourly rate Number of withholding allowances For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income tax withheld for...

  • Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll...

    Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,110 per week $28 per hour $50 per hour Overtime earnings rate Not applicable 1.5 times hourly rate 2 times hourly rate Number of withholding allowances 3 2 1 For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income tax withheld...

  • Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll Information is available for each employee: Computer Programmer Administrator Regular earnings rate Overtime earnings rate Number of withholding allowances Consultant $3,010 per week Not applicable $30 per hour 1.5 times hourly rate $50 per hour 2 times hourly rate For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income tax withheld for...

  • Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,510 per week $34 per hour $46 per hour Overtime earnings rate Not applicable 1.5 times hourly rate 2 times hourly rate Number of withholding allowances 3 2 1 For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income...

  • Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $28 per hour $3,310 per week Not applicable $46 per hour 2 times hourly rate 1.5 times hourly rate Overtime earnings rate Number of withholding allowances For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income tax withheld for...

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