Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will write a program that consists of 4 sub programs as described below payr

ID: 3686543 • Letter: Y

Question

You will write a program that consists of 4 sub programs as described below

payroll           1)   read input data     name, hours worked, bonus code, rate of pay

                        void ReadData (string &name, double& hours, int&bonusCode, double& rate)

                       2)   determine salary, including overtime   >40hours. rate = 2 times for overtime.

                              double Salary(double hours, double rate, int bonusCode)

                                    //note: bonusCode only needed as parameter if Salary calls Bonus

                    

                        3)   determine bonus…bonus = 100, 50, 25 , 0   depends on the code

                              code 0 -0    code = 1 $25, code 2-450, code 3 = $100

                           double Bonus(int bonusCode)

                                    // note: may be called by Salary or by main---you decide

                        4) prints the check

                            void PrintCheck(string name, double amtSalary)

One programmer is designated as the lead programmer and she/he will create and test the main program and functions 1 (done below) & 4. The other programmer will complete functions 2 & 3.

void ReadData (string &name, double& hours, int&bonusCode, double& rate)

{

    cin>>name>>hours>>bonusCde>>rate;   }

submit

(lead programmer submits, the other puts a message in the box indicating who she/he is working with)

source code for 4 functions and main program

copies of output from at least 3 trials of program

Explanation / Answer

#include<iostream>

using namespace std;

// function prototype
void ReadData (string &name, double& hours, int&bonusCode, double& rate);
double Salary(double hours, double rate, int bonusCode);
double Bonus(int bonusCode);
void PrintCheck(string name, double amtSalary);

int main(){
  
   string name;
   double hours;
   int bonusCode;
   double rate;
  
   //caling read function;
   ReadData(name, hours, bonusCode, rate);
  
   // calling Salary method
   double amtSalary = Salary(hours, rate, bonusCode);
  
   //calling print method
   PrintCheck(name, amtSalary);
  
   return 0;
}

void ReadData (string &name, double& hours, int&bonusCode, double& rate){
  
   cout<<"Enter name hours worked, nonus code and pay rate: "<<endl;
   cin>>name>>hours>>bonusCode>>rate;
}

double Salary(double hours, double rate, int bonusCode){
  
   double salary = 0;
  
   if(hours > 40){
       salary = rate*40 + (hours-40)*2*rate;
   }
   else{
       salary = rate*hours;
       }
   // adding bonus
   salary = salary + Bonus(bonusCode);
  
      
   return salary;
}

double Bonus(int bonusCode){
   if(bonusCode == 1)
       return 25;
   else if(bonusCode == 2)
       return 50;
   else if(bonusCode == 3)
       return 100;
   else
       return 0;
}

void PrintCheck(string name, double amtSalary){
   cout<<"Name: "<<name<<", Salary: "<<amtSalary<<endl;
}


/*

Sample run:

Enter name hours worked, nonus code and pay rate:
Pravesh
45
3
2300
Name: Pravesh, Salary: 115100

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote