include <iostream>
include <cmath>

using namespace std;

int main()

{


char flag;
float emp_no,basic,da ,hra,pf,tax,net_salary,total_salary;
cout<<"enter the basic salary & employee no.";
cin>>basic>>emp_no;
if(basic<=5000)
    flag=0;
else if(basic>5000&&basic<=15000)
    flag=1;
else if(basic>1500 && basic<=25000)
    flag=2;
switch(flag)
{
    case '0':
        tax=0;
        da=(25/100)*basic;
        hra=(20/100)*basic;
        pf=(5/100)*basic;
        break;
    case '1':
        tax=(10/100)*basic;
        da=(25/100)*basic;
        hra=(20/100)*basic;
        pf=(10/100)*basic;
        break;
    case '2':
        tax=(15/100)*basic;
        da=(35/100)*basic;
        hra=(25/100)*basic;
        pf=(15/100)*basic;
        break;
    default:
        tax=(20/100)*basic;
        da=(50/100)*basic;
        hra=(30/100)*basic;
        pf=(20/100)*basic;

}
net_salary=basic+da+hra;
total_salary=net_salary-pf-tax;
cout<<"the net salary of emplpyee no."<<emp_no<< "is"<<(basic+da+hra);
cout<< "and the total salary is "<<total_salary;
return 0;

Recommended Answers

All 2 Replies

What command are you using to compile this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.