Back To C++ Classes
in the code given below getdata() member function inputs data from user, calculate() member function calculates total salary as sum of basic,da and hra, showdata() function displays the data with total and percentage of student
//program to demonstrate example of class employee with data members as ecode,ename,designation,basic,hra,da and total) calculate total function calculates the total salary as sum of basic,da and hra , getdata function inputs data from user and showdata member function displays data #include
#include
class employee { int ecode; char ename[20]; float basic; float da; float hra; float total; char designation[20]; public: void getdata(); void calculatetotal(); void showdata(); }; void employee::getdata() { cout<<"\nenter employee code "; cin>>ecode; cout<<"\nenter employee name "; cin>>ename; cout<<"\nenter designation of employee "; cin>>designation; cout<<"\nenter basic salary "; cin>>basic; cout<<"\nenter dearness allowance "; cin>>da; cout<<"\nenter house rent allowance "; cin>>hra; } void employee::calculatetotal() { total=basic+da+hra; } void employee::showdata() { cout<<"\nemployee code is "<