StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 19. Program to read the data of `n` employees and compute the net salary of each employee (DA = 52% of basic and IT = 30% of the gross salary).
Download
  1. C++ Programs list
18. Program to allocate memory dynamically for an object of a given class using the class’s constructor. : 20. Program to find the maximum of two numbers using a friend function.
C++ Programs list

1.      Program to read the data of `n` employees and compute the net salary of each employee (DA = 52% of basic and IT = 30% of the gross salary).

  1. #include <iostream.h>

  2. #include <conio.h>

  3. class Employee {

  4. public:

  5.     int empId;

  6.     char name[50];

  7.     float basicSalary;

  8.  

  9.     void inputDetails() {

  10.                 cout << "Enter employee ID: ";

  11.                 cin >> empId;

  12.                 cout << "Enter employee name: ";

  13.                 cin.getline(name, 50);

  14.                 cout << "Enter basic salary: ";

  15.                 cin >> basicSalary;

  16.     }

  17.  

  18.     void calculateNetSalary() {

  19.                 float DA = 0.52 * basicSalary;

  20.                 float grossSalary = basicSalary + DA;

  21.                 float IT = 0.3 * grossSalary;

  22.                 float netSalary = grossSalary - IT;

  23.  

  24.                 cout << "Net salary of employee " << empId << ": " << netSalary << endl;

  25.     }

  26. };

  27.  

  28. int main() {

  29.     int n;

  30.  

  31.     cout << "Enter the number of employees(less then 100): ";

  32.     cin >> n;

  33.  

  34.     Employee employees[100];

  35.  

  36.     for (int i = 0; i < n; i++) {

  37.                 cout << "\nEnter details for employee " << i + 1 << endl;

  38.                 employees[i].inputDetails();

  39.                 employees[i].calculateNetSalary();

  40.     }

  41.     getch();

  42.     return 0;

  43. }

  44.  

18. Program to allocate memory dynamically for an object of a given class using the class’s constructor. 20. Program to find the maximum of two numbers using a friend function.
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website