Advertisement Area

Program #2: To Calculate the Gross Salary of Employee

C++ Language

#include<iostream.h>
#include<conio.h>
class employee
{
    private:
    char name[20];
    double basic_salary,gross_salary,da,hra;
    
    public:
    void getdata();
    void display();
};
void employee::getdata()
{
    cout<<"Enter the name of Employee "<<endl;
    cin>>name;
    cout<<"Enter the Basic Salary of Employee"<<endl;
    cin>>basic_salary;
}
void employee::display()
{
    cout<<"****************************"<<endl;
    cout<<"Name of the Employee - "<<name<<endl;
    cout<<"Basic Salary of the Employee - "<<basic_salary<<endl;
    da=0.5*basic_salary;
    hra=0.15*basic_salary;
    gross_salary=basic_salary+da+hra;
    cout<<"Gross Salary - "<<gross_salary<<endl;
    cout<<"Entered DA - "<<da<<endl;
    cout<<"Entered HRA - "<<hra<<endl;
    cout<<"*****************************"<<endl;
}
void main()
{
    clrscr();
    employee obj;
    obj.getdata();
    obj.display();
    getch();
}

/*OUTPUT*/
Enter the name of Employee
Alex
Enter the Basic Salary of Employee
8000
*****************************
Name of the Employee - Alex
Basic Salary of the Employee - 8000
Gross Salary - 13200
Entered DA - 4000
Entered HRA - 1200
*****************************