Advertisement
vvccs

employee

Jun 6th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. // Name: Aakash Netada
  2. // Roll no.: 52
  3. // Batch : S3
  4. // Q. Write a c++ program for calculating employee yearly salary and income tax.
  5. #include<iostream>
  6. #include <cstring>
  7. #include <iomanip>
  8. using namespace std;
  9. class taxpayer
  10. {
  11.     private:
  12.         char name[30];
  13.         int salary,gross,hra,da;
  14.         float tax;
  15.    
  16.     public:
  17.         taxpayer() // constructor making
  18.     {
  19.         name[30] = 0;
  20.         gross= 0;
  21.         tax = 0;
  22.         hra=0;
  23.         da=0;
  24.         salary=0;
  25.     }
  26.     void Input();
  27.     void formula();
  28.     void Calctax();
  29. };
  30. void taxpayer::Input()
  31. {
  32.     cout << "\nEnter Name : ";
  33.     cin >> name;
  34.     cout << "\nEnter Salary : ";
  35.     cin >> salary;
  36. }
  37. void taxpayer::formula()
  38. {
  39.         if(salary<= 100000)
  40.     {
  41.         da=salary*20/100;
  42.         hra=salary*80/100;
  43.         gross=salary+da+hra;
  44.     cout<<"the gross salary of the employee is="<<gross<<endl;
  45.     }
  46. if(salary<= 200000)
  47.     {
  48.         da=salary*25/100;
  49.         hra=salary*90/100;
  50.         gross=salary+da+hra;
  51.     cout<<"the gross salary of employee is="<<gross<<endl;
  52.     }
  53.     else if(salary>200000)
  54.     {
  55.         da=salary*30/100;
  56.         hra=salary*95/100;
  57.         gross=salary+da+hra;
  58.     cout<<"the gross salary of employee is="<<gross<<endl;
  59.     }
  60.     else if(salary>500000)
  61.     {
  62.         da=salary*45/100;
  63.         hra=salary*95/100;
  64.         gross=salary+da+hra;
  65.     cout<<"the gross salary of employee is="<<gross<<endl;
  66.     }
  67.     else
  68.     {
  69.         cout<<"you have no salary"<<endl;
  70.     }
  71. }
  72. void taxpayer::Calctax()
  73. {
  74.     if ( gross<= 100000)
  75.     {
  76.         tax = 0;
  77.         cout << "No tax is charged." << endl;
  78.     }
  79.     else if ( gross > 100000 &&  gross <= 200000)
  80.     {
  81.         tax = 0.1 *  gross;
  82.         cout << "Tax of 10% of total income is charged and the tax amount is : " << tax << endl;
  83.     }
  84.     else if ( gross > 200000 &&  gross <= 500000)
  85.     {
  86.         tax = 0.15 *  gross;
  87.         cout << "Tax of 15% of total income is charge and the tax amount is : " << tax << endl;
  88.     }
  89.     else
  90.     {
  91.         tax = 0.2 *  gross;
  92.         cout << "Tax of 20% of total income is charged and the tax amount is : " << tax << endl;
  93.     }
  94. }
  95. int main()
  96. {
  97.     taxpayer t;
  98.     t.Input();
  99.     t.formula();
  100.     t.Calctax();
  101.     return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement