# Income Tax Calculator

Page 1 of 1

## 10 Replies - 1091 Views - Last Post: 15 February 2014 - 06:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=339780&amp;s=b2bc245f8f5dada60186019a3da6c7df&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Symbianizer

Reputation: 0
• Posts: 6
• Joined: 11-February 14

# Income Tax Calculator

Posted 11 February 2014 - 07:52 AM

An employee is exempted from paying income tax if his monthly income is less than P833.00. However, if taxable income exceeds this amount, tax is computed based on the tax table below. Notice that tax rates depend on filing status (i.e. whether one is single or married, with or without dependents, and on the number of children) and income.

Write a program that (a) asks the user for (a.1) gross income (and checks whether the entered amount is not less than P833) and (a.2) filing status (and verifies correctness of value) ; (/> computes for tax and © prints income, filing status (in words) and tax.

Include the following functions: (You are free to add more functions.)

entered_gross_income – whose task is to read and verify the value typed by the user
for income
entered_filing_status - reads and verifies the value provided for the variable
filing_status
computed_tax - computes the tax
output_results - prints income, filing status (in words), and tax

Table: http://imgur.com/0hUJtFP

```//

#include <stdio.h>
#include <stdlib.h>

/*-----------------------------------------------------------------------------------------------------*/
int entered_gross_income(float *pg_income){

printf("Gross Income:\n");
scanf("%f", &*pg_income);

if(*pg_income < 833){
printf("You don't have to pay tax.\n");
}
return *pg_income >= 833;
}
/*-----------------------------------------------------------------------------------------------------*/
void entered_filing_status(int *pcategory, int *pexempt, int *pchildren )
{
printf("---------------------------------------------------------------------------------\n");
printf(" Monthly     1        2         3        4         5         6         7          8  \n");
printf(" Exemption  0.00     0.00     41.67    208.33     70833      1875     416.67   10,416.67 \n");
printf(" Status   +0 over   +5 over  +10 over +15 over  +20 over  +25 over  +30 over  +32 over\n");

printf("---------------------------------------------------------------------------------\n");
printf("Table for Employees without Qualified Dependent\n");
printf(" Z     0.0      1      0     833    2500     5833    11667     20833     41667\n");
printf(" S/ME  50       1    4167   5000    6667    10000    15833     25000     45833\n");
printf("---------------------------------------------------------------------------------\n");
printf("Table for Single/ Married Employee with Qualified Dependent Child(ren)\n");
printf(" ME1/S1    75   1    6250    7083    8750   12083   17917   27083    47917\n");
printf(" ME2/S2    100  1    8333    9167   10833   14167   20000   29167    50000\n");
printf(" ME3/S3    125  1   10417   11250   12917   16250   22083   31250    52083\n");
printf(" ME4/S4    150  1   12500   13333   15000   18333   24167   33333    54167\n");
printf("---------------------------------------------------------------------------------\n");

printf("What category are you in? Table A [1] or B[2]?\n");
scanf("%d", &*pcategory);

if(*pcategory == 1){
printf("Are you under Zero Exemption? [1]Yes [2] No\n");
scanf("%d", &*pexempt);

if(*pcategory == 2){
printf("Input number of children:\n ");
scanf("%d", &*pchildren);

}

double computed_tax ( int category, int exempt, int children, int g_income, float *ptax){
if( category == 1)
{
if(exempt == 1)
{
if(g_income <= 832){
g_income = g_income;
*ptax = 0;
}
else if(g_income >= 833 && g_income <= 2499){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 2500 && g_income <= 5832){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;
}
else if(g_income >= 5833 && g_income <= 11666){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;
}
else if(g_income >= 11667 && g_income <= 20832){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;
}
else if(g_income >= 20833 && g_income <= 41666){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;
}
else if(g_income >= 41667){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;
}

}
else if(g_income >)
}
else if(exempt == 2){
if(g_income <= 4167){
*ptax = (g_income *.05) + *ptax;
return (g_income *.1) ;
}
else if(g_income >= 4168 && g_income <= 5000){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 5001 && g_income <= 6667){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;
}
else if(g_income >= 6668&& g_income <= 10000){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;

}
else if(g_income >= 10001 && g_income <= 15833){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;

}
else if(g_income >= 15834 && g_income <= 25000){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;

}
else if(g_income >= 25001 && g_income <= 45833){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;

}
return tax;
}

}

else if(category == 2)
{
if(children == 1){
if(g_income <= 6249){
g_income = g_income;
*ptax = 0;
else if(g_income >= 6250 && g_income <= 7082){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 7083 && g_income <= 8749){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;

else if(g_income >= 8750 && g_income <= 12082){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;
else if(g_income >= 12083 && g_income <= 17916){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;
}
else if(g_income >= 17917 && g_income <= 27082){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;
}
else if(g_income >= 27083){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;

}
else if(children == 2){
if(g_income <= 8332){
g_income = g_income;
*ptax = 0;
}
else if(g_income >= 8333 && g_income <= 9166){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 9167 && g_income <= 10832){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;
}
else if(g_income >= 10833 && g_income <= 14166){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;
else if(g_income >= 14167 && g_income <= 19999){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;
}
else if(g_income >= 20000 && g_income <= 41666){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;
}
else if(g_income >= 41667){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;

}
else if (children == 3) {
if(g_income <= 832){
g_income = g_income;
*ptax = 0;
else if(g_income >= 833 && g_income <= 2499){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 2500 && g_income <= 5832){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;
}
else if(g_income >= 5833 && g_income <= 11666){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;
else if(g_income >= 11667 && g_income <= 20832){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;
}
else if(g_income >= 20833 && g_income <= 41666){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;
}
else if(g_income >= 41667){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;

}
else if (children == 4){
if(g_income <= 832){
g_income = g_income;
*ptax = 0;
else if(g_income >= 833 && g_income <= 2499){
*ptax = (g_income *.1) + *ptax;
return (g_income *.1) + 41.67;
}
else if(g_income >= 2500 && g_income <= 5832){
*ptax = (g_income *.15) + *ptax;
return (g_income *.1) + 208.33;
}
else if(g_income >= 5833 && g_income <= 11666){
*ptax = (g_income *.2) + *ptax;
return (g_income *.1) + 708.33;
}
else if(g_income >= 11667 && g_income <= 20832){
*ptax = (g_income *.25) + *ptax;
return (g_income *.25)+1875;
}
else if(g_income >= 20833 && g_income <= 41666){
*ptax = (g_income *.3) + *ptax;
return (g_income *.3)+4166.67;
}
else if(g_income >= 41667){
*ptax = (g_income *.32) + *ptax;
return (g_income *.32)+10, 416.67;

}

}
}

/*-----------------------------------------------------------------------------------------------------*/
void output_results(){
printf("Gross Income: %d", &g_income);

printf("Filed under: Table %d S%d/ME%d", &category, &children, &children);

printf("Tax: %d", &*ptax);
}
/*-----------------------------------------------------------------------------------------------------*/
int main()
{
printf("Tax Calculator\n");
printf("Provide the data needed.\n");
return 0;

}

```

Is This A Good Question/Topic? 0

## Replies To: Income Tax Calculator

### #2 modi123_1

• Suitor #2

Reputation: 10675
• Posts: 41,554
• Joined: 12-June 08

## Re: Income Tax Calculator

Posted 11 February 2014 - 07:56 AM

Is there a question in there?

### #3 Black_Epiphany

Reputation: 9
• Posts: 66
• Joined: 02-February 14

## Re: Income Tax Calculator

Posted 11 February 2014 - 04:02 PM

There is an error in line 102
```else if(g_income >= 6668&& g_income <= 10000){

```

should be

```else if(g_income >= 6668 && g_income <= 10000){
```

### #4 jimblumberg

Reputation: 4646
• Posts: 14,570
• Joined: 25-December 09

## Re: Income Tax Calculator

Posted 11 February 2014 - 04:14 PM

Quote

There is an error in line 102

Could you be more specific? I must be going blind, I don't see any difference between your two snippets (whitespace is not relevant except the one separating the if and the else).

Jim

This post has been edited by jimblumberg: 11 February 2014 - 04:15 PM

• جوروترا

Reputation: 275
• Posts: 962
• Joined: 18-April 09

## Re: Income Tax Calculator

Posted 11 February 2014 - 05:02 PM

@Black_Epiphany

What is the difference between your code and the OP ? can't seem to see any difference there.

### #6 Symbianizer

Reputation: 0
• Posts: 6
• Joined: 11-February 14

## Re: Income Tax Calculator

Posted 13 February 2014 - 03:39 AM

Black_Epiphany, on 11 February 2014 - 04:02 PM, said:

There is an error in line 102
```else if(g_income >= 6668&& g_income <= 10000){

```

should be

```else if(g_income >= 6668 && g_income <= 10000){
```

im using codeblocks and i encountered 5 errors.. how can i fix this
http://imgur.com/hoMeqok

### #7 jimblumberg

Reputation: 4646
• Posts: 14,570
• Joined: 25-December 09

## Re: Income Tax Calculator

Posted 13 February 2014 - 07:00 AM

Please cut and paste you errors into a post.

Jim

### #8 Symbianizer

Reputation: 0
• Posts: 6
• Joined: 11-February 14

## Re: Income Tax Calculator

Posted 13 February 2014 - 07:35 AM

jimblumberg, on 13 February 2014 - 07:00 AM, said:

Please cut and paste you errors into a post.

Jim

error: too few arguments to function 'computed_tax"
note: declared here
warning: passing argument 4 of 'output_results' makes pointer from integer without a cast (enabled by defualt)
note: expected 'double *' buut argument is of type 'int'
error: too many arguments to function 'output_results'
note: declared here
error: expected declaration or statement at end of input

### #9 jimblumberg

Reputation: 4646
• Posts: 14,570
• Joined: 25-December 09

## Re: Income Tax Calculator

Posted 13 February 2014 - 07:48 AM

You left off a very important part of your error messages, the line numbers. Plus those errors don't match your picture. Please try again. This time post all the error messages making sure they match the code you have posted. Remember error messages must be examined from the top down. Fixing the first error may fix several of the following errors.

Jim

### #10 Symbianizer

Reputation: 0
• Posts: 6
• Joined: 11-February 14

## Re: Income Tax Calculator

Posted 13 February 2014 - 07:53 AM

jimblumberg, on 13 February 2014 - 07:48 AM, said:

You left off a very important part of your error messages, the line numbers. Plus those errors don't match your picture. Please try again. This time post all the error messages making sure they match the code you have posted. Remember error messages must be examined from the top down. Fixing the first error may fix several of the following errors.

Jim

Thank you very much Jim..!
I started from the bottom but I'm still here

### #11 click_here

• D.I.C Regular

Reputation: 45
• Posts: 292
• Joined: 25-November 13

## Re: Income Tax Calculator

Posted 15 February 2014 - 06:57 PM

Where are the closing braces for these if statements?...
```void entered_filing_status(int *pcategory, int *pexempt, int *pchildren )

...
037
038
039	    printf("What category are you in? Table A [1] or B[2]?\n");
040	    scanf("%d", &*pcategory);
041
042	    if(*pcategory == 1){
043	        printf("Are you under Zero Exemption? [1]Yes [2] No\n");
044	        scanf("%d", &*pexempt);
045
046	     if(*pcategory == 2){
047	        printf("Input number of children:\n ");
048	        scanf("%d", &*pchildren);
049
050	    }
051
052	double computed_tax ( int category, int exempt, int children, int g_income, float *ptax){
053

```

Also, if you are using a pointer with scanf, don't use "&*" - It's redundent and looks odd...