Employee.cpp
1 #include <iostream> 2 3 using namespace std; 4 5 class Employee { 6 7 private: 8 int empID; 9 string empName; 10 double basicSalary; 11 12 public: 13 void accept() { 14 cout << "Enter Employee ID: "; 15 cin >> empID; 16 cin.ignore(); 17 cout << "Enter Employee Name: "; 18 getline(cin, empName); 19 cout << "Enter Basic Salary: "; 20 cin >> basicSalary; 21 } 22 void display() { 23 double DA = 0.25; 24 DA *= basicSalary; 25 double HRA = 800; 26 double IncomeTax = 0.15; 27 IncomeTax *= basicSalary; 28 double netSalary = basicSalary + DA + HRA - IncomeTax; 29 30 cout << left << "\nEmployee ID: " << empID << endl; 31 cout << left << "Employee Name: " << empName << endl; 32 cout << left << "Basic Salary: " << fixed << basicSalary << endl; 33 cout << left << "DA: " << DA << endl; 34 cout << left << "HRA: " << HRA << endl; 35 cout << left << "Income Tax: " << IncomeTax << endl; 36 cout << left << "Net Salary: " << netSalary << endl; 37 } 38 }; 39 40 int main() { 41 // Employee Employee; 42 // Employee.accept(); 43 // Employee.display(); 44 45 Employee *ThisPointerEmployee = new Employee(); 46 ThisPointerEmployee->accept(); 47 ThisPointerEmployee->display(); 48 delete ThisPointerEmployee; 49 50 return 0; 51 }