Write a c++ program to input basic salary of an employee and calculate its Gross salary according to following

Basic Salary <25000 : HRA =20%,DA=80%
Basic salary >= 25000: HRA=25%,DA=90%
Basic Salary >= 40000:HRA=30%,DA=95%​

Respuesta :

[tex]\large\bold{\underline{\underline{Program :}}}[/tex]

#include<iostream>

using namespace std;

int main ()

{

float basic, gross, da, hra;

cout<<"Enter basic salary of an employee:";

cin>>basic;

if (basic <25000)

{

da = basic *80/100;

hra = basic *20/100;

}

else if (basic >=25000 & & basic<40000)

{

da = basic *90/100;

hra = basic *25/100;

}

else if (basic>=40000)

{

da = basic *95/100;

hra = basic *30/100;

}

gross = basic + hra + da;

cout<<"\n\t Basic Pay............" <<basic<<endl;

cout<<"\t Dearness Allowance..........." <<da<<endl;

cout<<"\t House Rent Allowance......" <<hra<<endl;

cout<<"\t Gross Salary............." <<gross<<endl;

cout<<"\t - - - - - - - - - - - - - - -" <<endl;

[tex]\large\bold{\underline{\underline{Output :}}}[/tex]

Enter Basic Salary of an employee : 25000

Basic Pay : 25000

Dearness Allowance : 22500

House Rent Allowance : 6250

Gross Salary : 53750

[tex]\large\bold{\underline{\underline{Result :}}}[/tex]

The Expected Output is archived

Using the knowledge of code in c++ we have to be the same as the attached image.

In a simpler way, we have that this code can be described as:

#include<iostream>

using namespace std;

int main ()

{

float basic, gross, da, hra;

cout<<"Enter basic salary of an employee:";

cin>>basic;

if (basic <25000)

{

da = basic *80/100;

hra = basic *20/100;

}

else if (basic >=25000 & & basic<40000)

{

da = basic *90/100;

hra = basic *25/100;

}

else if (basic>=40000)

{

da = basic *95/100;

hra = basic *30/100;

}

gross = basic + hra + da;

cout<<"\n\t Basic Pay............" <<basic<<endl;

cout<<"\t Dearness Allowance..........." <<da<<endl;

cout<<"\t House Rent Allowance......" <<hra<<endl;

cout<<"\t Gross Salary............." <<gross<<endl;

cout<<"\t - - - - - - - - - - - - - - -" <<endl;

See more about C++ code at brainly.com/question/25870717

Ver imagen lhmarianateixeira