Solution:
#include<iostream>
using namespace std;
class WorkerInformation {
char Worker_Name[50];
int No_Of_Hours_Worked, Salary;
public:
void acccept() {
cout << "Enter name of the worker: ";
cin >> Worker_Name;
cout << "Enter number of hours worked: ";
cin >> No_Of_Hours_Worked;
}
void display() {
cout << endl << "Worker details" << endl;
cout << "Name: " << Worker_Name << endl;
cout << "Salary: " << calSal(No_Of_Hours_Worked) << endl;
}
int calSal(int work_hrs, int pay_rate=100) {
return (work_hrs*pay_rate);
}
};
int main() {
WorkerInformation w;
w.acccept();
w.display();
return 0;
}
0 Comments