C++ Project – Calculate Employee Salary

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// Project to calcluate employee salary
/*
    empid 
    empname and dept
    BS between 5000 to 10000
    HRA between 2000 to 5000
    TA between 3000 to 6000
    DA between 3000 to 6000
    LIC between 2500 to 5000
    GS=(BS+HRA+TA+DA)-LIC;
*/
#include<iostream>
using namespace std;
int main()
{
     int empid,bs,hra,ta,da,lic,gs;
     string name,dept;
     system("cls");
     cout<<"\nEnter Employee Id:";
     cin>>empid;
     cout<<"\nEnter Employee Name:";
     cin>>name;
     cout<<"\nEnter Department:";
     cin>>dept;
    
     BASIC:cout<<"\nEnter Basic Salary: ";
     cin>>bs;
     if (!(bs>=5000 && bs<=10000))
     {
       cout<<"Invalid data enter again[ Enter Between 5000 to 10000]";
       goto BASIC;
     }
     HRA:cout<<"\nEnter HRA: ";
     cin>>hra;
     if (!(hra>=2000 && hra<=5000))
     {
       cout<<"Invalid data enter again[ Enter Between 2000 to 5000]";
       goto HRA;
     }
     TA:cout<<"\nEnter TA: ";
     cin>>ta;
     if (!(ta>=3000 && ta<=6000))
     {
       cout<<"Invalid data enter again[ Enter Between 3000 to 6000]";
       goto TA;
     }

     DA:cout<<"\nEnter DA: ";
     cin>>da;
     if (!(da>=3000 && da<=6000))
     {
       cout<<"Invalid data enter again[ Enter Between 3000 to 6000]";
       goto DA;
     }

     LIC:cout<<"\nEnter LIC: ";
     cin>>lic;
     if (!(lic>=2500 && lic<=5000))
     {
       cout<<"Invalid data enter again[ Enter Between 2500 to 5000]";
       goto LIC;
     }

    gs=(bs+hra+ta+da)-lic;
    cout<<"\n----------------------------------------------";
    cout<<endl<<"Employee id: "<<empid;
    cout<<endl<<"Employee name: "<<name;
    cout<<endl<<"Department:"<<dept;
    cout<<endl<<"Gross Salary: "<<gs;
    cout<<"\n----------------------------------------------";
    return 0;
}

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *