Write a C++ program to create a class Employee which contains data members as Emp_Id, Emp_Name, Basic_Salary, HRA, DA, Gross_Salary. Write member functions to accept Employee information. Calculate and display Gross salary of an employee. (DA=12% of Basic salary and HRA = 30% of Basic salary) (Use appropriate manipulators to display employee information in given format :- Emp_Id and Emp_Name should be left justified and Basic_Salary, HRA, DA, Gross salary Right justified with a precision of two digits)
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio.h>
#include<iostream.h>
#include<iomanip.h> //manipulator
class emp
{
public:
int eid; //eid=employee id
float bsal,hra,da,gsal; //bsal=basic salary , hra=HRA , da=DA , gsal=Gross salary
char name[10]; //name=name of employee
void accept()
{
cout<<"Enter employee id: ";
cin>>eid;
cout<<"Enter employee name: ";
cin>>name;
cout<<"Enter basic salary: ";
cin>>bsal;
}
void disp()
{
cout.precision(2); //manipulator
cout.left;
cout<<"employee id: "<<setw(20)<<eid<<endl;
cout<<"employee name: "<<setw(20)<<name<<endl;
cout<<"basic salary: "<<bsal<<endl;
cout<<"HRA: "<<hra<<endl;
cout<<"DA: "<<da<<endl;
cout<<"Gross salary: "<<gsal<<endl;
}
void cal() //calculate gross salary
{
hra=((30.0/100)*bsal);
da=((20.0/100)*bsal);
gsal=bsal+hra+da;
}
};
int main()
{
emp e; //creating instance of class emp
e.accept(); //calling member functions
e.cal();
e.disp();
getch();
return(0);
}
-
Next Create a class Date containing members as: - dd - mm - yyyy Write a C++ program for overloading operators >> and << to accept and display a Date also write a member function to validate a date.
-
Previous Create a Base class Train containing protected data members as Train_no, Train_Name. Derive a class Route (Route_id, Source, Destination) from Train class. Also derive a class Reservation(Number_Of_Seats, Train_Class, Fare, Travel_Date) from Route. Write a C++ program to perform following necessary functions : i. Enter details of ‘n’ reservations ii. Display details of all reservations iii. Display reservation details of a specified Train class
0 Comments