Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Lab # 4

Nested If Else Statement


Programming Fundamentals Lab (EE-112L)
Contents
• Problem Statement
• Flow Charts
• Code Solution
Problem statement
• Suppose a condition depends upon another condition
• A person has to pay tax only if his/her annual income is greater than 500,000
• If the person is taxable then
• If his income is between 5 lacs and 8 lacs, the tax is 5% of his annual income
• If his income is between 8 and 10 lacs, the tax is 7% of his annual income
• If the income is greater than 10 lacs, the tax is a sum of 1 lac and 3% of his income
greater than 10 lacs
start

Flow Chart Enter monthly


income

Yearly
amount=12*monthly If (amount <8lac) YES Tax=amount
income
*0.05

YES NO

If (amount
>5lac)
If (amount YES Tax=amount
<10lac)
NO *0.07

ELSE
Tax=1lac+
(amount>10lc)*0.03

Show Tax
Amount

end
Code
#include <stdio.h>
int main()
{
while(1){
printf("Enter Your Monthly Income: ");
int monthlyIncome=0;
int taxAmount=0;
scanf("%d", &monthlyIncome);
int annualIncome = 12 * monthlyIncome; //converts monthly to yearly income
if (annualIncome > 500000) {
if (annualIncome < 800000)
taxAmount = annualIncome * 0.05;
else if (annualIncome < 1000000)
taxAmount = annualIncome * 0.07;
else
taxAmount = 100000 + (annualIncome - 1000000) * 0.03;
}
else
taxAmount = 0;
printf("Annual Income is %d\n", annualIncome);
printf("Your Tax amount of your annual income is: %d\n", taxAmount);
printf("Remaining amount after tax is %d\n", annualIncome - taxAmount);
}
}
Output
The End

You might also like