Write a function that accepts a salary and returns the tax.
Write a function that accepts a salary and returns the tax.
This is a function that will accept a salary from the user and return the output tax according to the following rules:
For Example: If the salary is Rs.4000, then the tax is Rs.120.
The program is given below:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int sal, Tax = 0;
cout << "Enter your salary: ";
cin >> sal;
while (sal !=0)
{
if(sal == 0)
{
break;
}
else if(sal >= 1000 && sal <=2000)
{
Tax += (sal*0.04);
}
else if(sal >= 2000 && sal <= 3000)
{
Tax += (sal*0.04);
}
else if(sal >= 3000)
{
Tax += (sal*0.03);
}
sal/= 1000;
}
cout << "Tax: " << Tax << endl;
system("pause");
}
Comments
Post a Comment