Thursday, 7 March 2019

CPP-EX6


Write a c++ program to create a class Worker with data member as Worker_name,No_of_hours_worked,Pay_Rate. Write necessary member  function to calculate and display the salary of worker.(Use defalut value for Pay_rate). */

#include<iostream.h>
#include<conio.h>
class Worker
{
char Worker_name[20];
int salary;
int No_of_hours_worked;
int Pay_rate;
public:
void getdata();
void putdata(int);
};

void Worker::getdata()
{
cout<<"\n\nEnter the name of the Worker:";
cin>>Worker_name;
cout<<"\n\nEnter the Number of hours Worked:";
cin>>No_of_hours_worked;
}

void Worker::putdata(int Pay_rate)
{
cout<<"\n\n*********** Worker Details ***********";
cout<<"\n\n1.Worker Name:"<<Worker_name;
cout<<"\n2.No_of_hours_worked:"<<No_of_hours_worked;
salary=(No_of_hours_worked*Pay_rate);
cout<<"\n\n3.Salary of the Worker:Rs."<<salary;
}
int main()
{
Worker w;
clrscr();
w.getdata();
w.putdata(348);
getch();
return 0;
}