Design a flow chart and write an interactive program for the problem given below: Assume that the United States of America uses the following income tax code formula for their annual income:
First US$ 5000 of income: 0% tax
Next US$ 10,000 of income: 10% tax
Next US$ 20,000 of income: 15% tax
An amount above US$ 35,000: 20% tax.
For example, somebody earning US$ 38,000 annually
would owe US$ 5000 X 0.00+ 10,000 X 0.10 + 20,000 X 0.15 + 3,000 X 0.20,
which comes to US$ 4600. Write a program that uses a loop to input the income and calculate and report the owed tax amount. Make sure that your calculation is mathematically accurate and that truncation errors are eliminated
#include<stdio.h>
#include<conio.h>
void main()
{
float income,i=0,j=0,k=0,tax=0;
clrscr();
printf("\n\n\t\tEnter Your Income Tax -> ");
scanf("%f",&income);
/*--------Calculate The Tax---------*/
if(income>35000)
{
income=income-35000;
i=10000*.10;
j=20000*.15;
k=income*.20;
tax=i+j+k;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>20000 && income<=35000)
{
income=income-15000;
i=10000*.10;
j=income*.15;
tax=i+j;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>10000 && income<=20000)
{
income=income-15000;
i=10000*.10;
j=income*.15;
tax=i+j;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>5000 && income<=10000)
{
income=income-5000;
tax=income*.10;
printf("\n\n\t\tYour Tax is %f",tax);
}
else
{
printf("\n\n\t\t You have no tax");
}
getch();
}
First US$ 5000 of income: 0% tax
Next US$ 10,000 of income: 10% tax
Next US$ 20,000 of income: 15% tax
An amount above US$ 35,000: 20% tax.
For example, somebody earning US$ 38,000 annually
would owe US$ 5000 X 0.00+ 10,000 X 0.10 + 20,000 X 0.15 + 3,000 X 0.20,
which comes to US$ 4600. Write a program that uses a loop to input the income and calculate and report the owed tax amount. Make sure that your calculation is mathematically accurate and that truncation errors are eliminated
#include<stdio.h>
#include<conio.h>
void main()
{
float income,i=0,j=0,k=0,tax=0;
clrscr();
printf("\n\n\t\tEnter Your Income Tax -> ");
scanf("%f",&income);
/*--------Calculate The Tax---------*/
if(income>35000)
{
income=income-35000;
i=10000*.10;
j=20000*.15;
k=income*.20;
tax=i+j+k;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>20000 && income<=35000)
{
income=income-15000;
i=10000*.10;
j=income*.15;
tax=i+j;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>10000 && income<=20000)
{
income=income-15000;
i=10000*.10;
j=income*.15;
tax=i+j;
printf("\n\n\t\tYour Tax is %f",tax);
}
else if(income>5000 && income<=10000)
{
income=income-5000;
tax=income*.10;
printf("\n\n\t\tYour Tax is %f",tax);
}
else
{
printf("\n\n\t\t You have no tax");
}
getch();
}
0 टिप्पणियाँ:
Post a Comment