Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
November 10th, 2012, 02:12 PM
 nhockon0201
Registered User

Join Date: Nov 2012
Posts: 2
Time spent in forums: 1 h 26 m 57 sec
Reputation Power: 0
Help Please: Income tax calulator with Functions and Robus validation

Code:
```#include <conio.h>
#include <stdio.h>
#include <stdlib.h>

float tax(float t);
void clear (void);
main()
{
do
{
float income, pc,hi, charity, t, taxincome, net;
char a[0], b[0],c,choose;
int nod,ch,flag=0;
int person = 4000;

printf("\n Choose one of the following options:");
printf("\n 1. Tax calcultor:");
printf("\n 0. Exit");
printf("\n Income tax calculator");
printf("\n =====================");
printf("\n Income for the current month <in thousand VND>:"); scanf("%f%c", &income,&c);
while (1)
{
printf("\n Pension contribution <5%%> y/n?"); scanf("%s", &a);
if (a[0]=='y' || a[0]=='Y' || a[0]=='n' || a[0]=='N')
break;
else
printf("\n You must press 'Y' or 'N' only, try again");
}
printf("\n");
while (1)
{
printf("\n Health insurance <1%%> y/n?"); scanf("%s", &b);
if (b[0]=='y' || b[0]=='Y' || b[0]=='n' || b[0]=='N')
break;
else
printf("\n You must press 'Y' or 'N' only, try again");
}
printf("\n Number of Dependants <18 years old:"); scanf("%d", &nod);
printf("\n Charity:"); scanf("%f", &charity);
if (a[0] =='y' || a[0] == 'Y')
pc=income*0.05;
else
pc=0.0;
if (b[0] == 'y' || b[0] == 'Y')
hi=income*0.01;
else
hi=0.0;
t = income-(4000.0 + pc + hi + 1600.0*nod + charity);
taxincome = tax(t);
printf("\n Gross Income: %.1f", income);
printf("\n Deduction");
printf("\n Personal allowance :    %.1d", person);
printf("\n Pension contribution:   %.1f", pc);
printf("\n Health insurance:       %.1f", hi);
printf("\n Dependant:              %.1f", 1600.0*nod);
printf("\n Charity:                %.1f", charity);
printf("\n -----------------------------");
printf("\n Total:                  %.1f", t);
printf("\n Taxable Income:         %.1f", taxincome);
printf("\n Net income:             %.1f", income-taxincome);
printf("\n =============================");
printf("\n Another run <y/n>?");
}
while (getch() == 'y' || getch() == 'Y');
getch();
}
float tax(float t)
{
float taxincome;
if (t <= 5000)
taxincome = t*0.05;
else if (t <= 10000)
taxincome = 5000*0.05 +(t-5000)*0.1;
else if (t <=18000)
taxincome = 5000*0.05 + 5000*0.1 + (t-10000)*0.15;
else if (t <=32000)
taxincome = 5000*0.05 + 5000*0.1 + 8000*0.15 + (t-18000)*0.2;
else if (t <=52000)
taxincome = 5000*0.05 + 5000*0.1 + 8000*0.15 + 14000*0.2 + (t-32000)*0.25;
else if (t <= 80000)
taxincome = 5000*0.05 + 5000*0.1 + 8000*0.15 + 14000*0.2 + 20000*0.25 + (t-52000)*0.3;
else
taxincome =  5000*0.05 + 5000*0.1 + 8000*0.15 + 14000*0.2 + 20000*0.25 + 28000*0.3 + (t-80000)*0.35;
return taxincome;
}```

• input is negative in value
• more than one decimal point appears in floating-point input
• characters are embedded in numeric input
• character is different from ‘y’ and ‘n’
• gift of charity exceeds the income
• a decimal point appear in integer input

#2
November 10th, 2012, 02:22 PM
 dwise1_aol
Contributing User

Join Date: Jan 2003
Location: USA
Posts: 6,854
Time spent in forums: 3 Months 1 Day 3 h 53 m 42 sec
Reputation Power: 2199

#3
November 10th, 2012, 02:42 PM
 nhockon0201
Registered User

Join Date: Nov 2012
Posts: 2
Time spent in forums: 1 h 26 m 57 sec
Reputation Power: 0
Quote:
 Originally Posted by dwise1_aol What is your question?

sr, I'd like to add to my program,code check for data input
exemple program here:
h t t p s://d o c s.google.com/open?id=0Bwxp1E3hkvUGRk8ySmdMbVIxQVk

#4
November 10th, 2012, 04:33 PM
 dwise1_aol
Contributing User

Join Date: Jan 2003
Location: USA
Posts: 6,854
Time spent in forums: 3 Months 1 Day 3 h 53 m 42 sec
Reputation Power: 2199
I repeat: what is your question?

Post your code here, formatted and with code tags.

#5
November 10th, 2012, 05:33 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,140
Time spent in forums: 1 Month 3 Weeks 2 Days 7 h 17 m 40 sec
Reputation Power: 455
Who in their right mind will run your program? I can't, because I use a unix version and won't install the windows virtual box or whatever.
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Help Please: Income tax calulator with Functions and Robus validation