‘if-else-if’ ladder exercise
In this article, let’s do one exercise using an if-else-if ladder.
Exercise:
Write a program to calculate the income tax payable of the user. The tax is calculated as per the below table.
The formula to calculate the Tax is Tax payable = Income *(tax rate/100). Tax rate is given in Figure 1.
For this application, your program has to first ask the user about the total income. So, you have to get the total income by the user, so then multiply with the appropriate tax rate to the income to calculate the tax payable, and then you can print the tax. I want you to code this exercise using if-else-if statements.
How the output of this exercise looks like is shown in Figure 2 and Figure 3.
First, it should ask the user to enter the total income, I type 1000 dollars, and it should give me the tax payable. In this case, it is 0.
If I type 100000, it should give the tax payable as $33000.
So, try to do this exercise, and in the following article, I will code for this exercise.
FastBit Embedded Brain Academy Courses
Click here: https://fastbitlab.com/course1