The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Help Please: Income tax calulator with Functions and Robus validation
Discuss Help Please: Income tax calulator with Functions and Robus validation in the C Programming forum on Dev Shed. Help Please: Income tax calulator with Functions and Robus validation C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 10th, 2012, 01:12 PM
|
|
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
|

November 10th, 2012, 01:22 PM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
What is your question?
|

November 10th, 2012, 01:42 PM
|
|
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
|

November 10th, 2012, 03:33 PM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
I repeat: what is your question?
Post your code here, formatted and with code tags.
And state your question.
|

November 10th, 2012, 04:33 PM
|
 |
Contributing User
|
|
|
|
|
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!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|