C++ program:
Salary calculation project in c++:
Program to calculate net salary of an employee:
C++ salary calculation program of employee:
Program that inputs the salary of an employee from the user.
Source code:
#include<iostream>// iostream provides basic
// input and output services for C++ programs
#include<math.h> // Is used to perform mathematical operation
using namespace std;
int main ()// Th execution of program start with the main function
{
int Salary;
float tax, netsal;
cout<<"Enter employee Salary:";
// cout is used to display the same statement in the output.
cin>>Salary;// Cin used to enter a value by the user.
if(Salary>30000)/* if else statement Use if to specify
a block of code to be executed,
if a specified condition is true. */
{
tax=(Salary*0.02);
netsal=Salary-tax;
}
else if(Salary>=20000)
/* Use else if to specify a new condition to test,
if the first condition is false.*/
{
tax=Salary*0.15;
netsal=Salary-tax;
}
else /* Use else to specify a block of code to be executed,
if the same condition is false.*/
{
tax=Salary*0.01;
netsal=Salary-tax;
}
cout<<"The salary is:
"<<Salary<<"\nThe income tax is:
"<<tax<<"\nThe net salary after detucting is:"<<netsal;
return 0;
}
0 Comments