Saturday 29 March 2014

Program To Calculate and Report the Owed Income Tax Amount

/* Assume that the United States of America uses the following income tax code formula for their annual income:
First US$ 5,000 of income: 0% tax
Next US$ 10,000 of income: 10% tax
Next US$ 20,000 of income: 15% tax
Next  Amount upto and above US$ 35,000: 20% tax.
For example, somebody earning US$ 38,000 annually would owe

US$ 5,000 X 0.00 + 10,000 X 0.10 + 20,000 X 0.15 + 3,000 X 0.20, which comes to US$ 4,600. */

main()
{
 float amt,t1,t2,i,tax;
 int c;
 clrscr();
 while(1)
 {
  printf("Enter your income in U.S. $ --> ");
  scanf("%f",&amt);
  if(amt<5000)
  {
   tax=amt*0.00;
  }
  else if(amt<=10000)
  {
   t1=amt-5000;
   tax=t1*0.10;
  }
  else if(amt<=20000)
  {
   t1=amt-5000;
   if(t1<10000)
   {
    tax=t1*0.10;
   }
   else
   {
    t2=t1-10000;
    tax=(10000*0.10)+t2*0.15;
   }
  }
  else if(amt>20000)
  {
   t1=amt-5000;
   t2=t1-10000;
   if(t2<=20000)
    tax=(10000*0.10)+t2*0.15;
   else
   {
    t2-=20000;
    tax=(10000*0.10)+(20000*0.15)+t2*0.20;
   }
  }
  printf("Your owed tax amount is %.2f $.",tax);
  printf("\nPress 1 to calculate another one or any number to exit. ");
  scanf("%d",&c);
  if(c==1)
   printf("\n");
  else
   exit(0);
 }
}

OutPut:

No comments:

Post a Comment