14. Program that inputs the salary of an employee from the user. It deducts the income tax from the salary. The program finally displays salary, income tax and the net salary.

Chapter 5: 

Conditional Structures

Programming Exercise

Problem # 14:

Write a program that inputs the salary of an employee from the user. It deducts the income tax from the salary on the following basis:
20% income tax if the salary is above Rs. 30000.
15% income tax if the salary is between Rs.20000 and Rs.30000.
10% income tax if the salary is below Rs.20000.
The program finally displays salary, income tax and the net salary.

Solution:

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main ()
{
    int sal;
    float tax, netsal;
    cout<<"Enter salary";
    cin>>sal;
    if(sal>30000)
    {
        tax=(sal*0.02);
        netsal=sal-tax;
    }
    else if(sal>=20000)
    {
        tax=sal*0.15;
        netsal=sal-tax;
    }
    else
    {
        tax=sal*0.01;
        netsal=sal-tax;
    }
    cout<<"The salary is:"<<sal<<"\nThe income tax is:"<<tax<<"\nThe net salary after detucting is:"<<netsal;
    return 0;
}


Let me know in the comment section if you have any question.

Previous Post:
13. Program that will take three values a, b and c and print the roots, if real, of the quadratic equation ax^2 + bx + c = 0.

Comments