Designer Jeans Shirt 40 20 Item #2 34.9s 24.95 Item #3 6. Payro11 Class Design a
ID: 3751186 • Letter: D
Question
Designer Jeans Shirt 40 20 Item #2 34.9s 24.95 Item #3 6. Payro11 Class Design a and number of hours worked. Write ro11 class that has fields for an employee's name, ID number, hourly pay rate, te the appropriate accessor and mutator methods, and Pay d mutatot appro constructor that accepts the employee's name and ID number as r as arguments. The dlass The dass a construc the number of hours worked multiplied by the hou employee. The program sho 7. Widget Factory argument is the number of widgets that must be produced. The class should have another a method that returns the employee's gross pay, which is calculated au program that dem- for an rly pay rate. Write a e user to enter the data onstrates the class by creating a Payroll object, then asks th uld display the amount gross pay earned. Design a class for a widget manufacturing plant. The class should have a method whose method that calculates how many days it will take to produce the number of widgets. Assume 10 widgets can be produced each hour. The plant operates two shifts of eight hours each per day.)Explanation / Answer
//C++ program
#include<iostream>
#include<math.h>
using namespace std;
//Payroll class
class payroll{
private:
string name;
string id;
double pay_rate;
double worked;
public :
payroll(string n ,string id){
this->name=n;
this->id=id;
}
void setPayRate(double r){
this->pay_rate=r;
}
void hourWorked(double w){
this->worked=w;
}
double Earned(){
return pay_rate*worked;
}
};
//Widget class
class widget{
int number;
public :
widget(int num){
this->number=num;
}
void setNumber(int num){
this->number=num;
}
int getNumber(){
return number;
}
int days(){
return ceil(0.1*this->number/24);
}
};
int main(){
string name,id;
double r,w;
int num;
cout<<"Enter name : ";
cin>>name;
cout<<"Enter id : ";
cin>>id;
payroll emp(name,id);
cout<<"Enter pay rate :";
cin>>r;
emp.setPayRate(r);
cout<<"Enter hour worked : ";
cin>>w;
emp.hourWorked(w);
cout<<"pay Earned : "<<emp.Earned();
cout<<" Enter number of widgets to produce : ";
cin>>num;
widget wid(num);
cout<<"Days taken to produce "<<wid.getNumber()<<" widgets = "<<wid.days()<<" ";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.