-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathch9_prog_proj_02.c
56 lines (46 loc) · 858 Bytes
/
ch9_prog_proj_02.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* ch9_prog_proj_02.c
*
* Created on: Oct 25, 2019
* Author: SuperMoudy
*/
// Programming Project 2: tax income
#include <stdio.h>
float compute_tax(float income);
int main(void)
{
float income;
printf("Enter the taxable income: ");
scanf("%f", &income);
printf("Tax due = %f", compute_tax(income));
return 0;
}
float compute_tax(float income)
{
float tax = 0.0f;
if(income > 0 && income <= 750)
{
tax = 0.01f * income;
}
else if(income > 750 && income <= 2250)
{
tax = 7.5f + 0.02f * income;
}
else if(income > 2250 && income <= 3750)
{
tax = 37.50f + 0.03f * income;
}
else if(income > 3750 && income <= 5250)
{
tax = 82.50f + 0.04f * income;
}
else if(income > 5250 && income <= 7000)
{
tax = 142.50f + 0.05f * income;
}
else if(income > 7000)
{
tax = 230.00f + 0.06f * income;
}
return tax;
}