Computer Science, asked by shaf016462, 8 months ago

write a program in c++ if a company an employee is paid as under:

• If his basic salary is less than Rs. 5000, then HRA = 10% of basic salary

and DA= 90% of basic salary.

• If his salary is either equal to or above Rs. 5000 but less than 15000, then HRA = Rs. 500 and DA = 98% of basic salary.

• If his salary is either equal to or above Rs. 15000, then HRA = Rs. 300 and DA= 99% of basic salary.

If the employee's salary is input by the user write a C++ program to find his gross salary. Where gross_salary=basic_salary+HRA+DA.​

Answers

Answered by BushrajavediqbalKhan
0

Explanation:

Program is written below

#include<iostream>

using namespace std;

int main()

{

float basic_salary, gross_salary, HRA, DA;

cout<<"Enter basic salary of Employee : ";

cin>>basic_salary;

if (basic_salary<1500)

{

 HRA=0.1*basic_salary;

 DA=0.9*basic_salary;

}

else

{  

 HRA=500;

 DA=0.98*basic_salary;

}

gross_salary=basic_salary+HRA+DA;

cout<<"Gross salary is : "<<gross_salary;

 

return 0;

}

Answered by AskewTronics
0

The c++ program for the above question is stated below:

Explanation:

#include <iostream> // header file

using namespace std;

int main() // main function definition.

{

   float gross_salary, basic_salary, DA, HRA; // declare three variable of float type.

   cin>>basic_salary; // take the input from the user for salary.

  if (basic_salary<5000) // check that the salary is less than 5000.

    gross_salary = basic_salary+(0.1*basic_salary)+(0.9*basic_salary); //calculate the gross salary for if statement.

  else if(basic_salary<15000) // check that the salary is less than 15000 and greater than or equal to 5000.

     gross_salary = basic_salary+ 500 + (0.98*basic_salary); // calculate the gross salary for the else if statement.

   else

       gross_salary = basic_salary+ 300 + (0.99*basic_salary);// calculate the gross salary for the else statement.

  cout<<"Gross salary is : "<<gross_salary; // print the gross salary.

  return 0; // return statement.

}

Output:

  • If the user inputs 4 then the output is 8
  • If the user inputs is 5000 then the output is 10400

Code Explanation:

  • The above program take the inputs of the salary and print the gross salary by the help of formula which is defined in the question.

Learn More:

  • Program: https://brainly.in/question/9996665
Similar questions