Write a c program in which the user enters his/her salary and the program computes the relevant tax according to the table below
SALARY RANGE. TAX(%)
<=170000. 0%
170000 - 360000. 11%
360,000 - 540000. 20%
540000 - 720000. 25%
>720000. 30%
#include <iostream>
int main()
{
int salary;
std::cout << "Enter your salary: \n";
std::cin >> salary;
int tax;
if (salary <= 170000)
{
tax = 0;
}
else if (salary > 170000 && salary <= 360000)
{
tax = 11;
}
else if (salary > 360000 && salary <= 540000)
{
tax = 20;
}
else if (salary > 540000 && salary <= 720000)
{
tax = 25;
}
else tax = 30;
double net_salary = static_cast<double>(salary) - static_cast<double>(salary) * static_cast<double>(tax) / 100;
std::cout << "Your net salary is " << net_salary << "\n";
return 0;
}
Comments
Leave a comment