C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 10th, 2012, 01:12 PM
nhockon0201 nhockon0201 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 nhockon0201 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old November 10th, 2012, 01:22 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,138 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 22 h 31 m 19 sec
Reputation Power: 1974
What is your question?

Reply With Quote
  #3  
Old November 10th, 2012, 01:42 PM
nhockon0201 nhockon0201 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 nhockon0201 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old November 10th, 2012, 03:33 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,138 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 22 h 31 m 19 sec
Reputation Power: 1974
I repeat: what is your question?

Post your code here, formatted and with code tags.

And state your question.

Reply With Quote
  #5  
Old November 10th, 2012, 04:33 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 29 sec
Reputation Power: 383
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Help Please: Income tax calulator with Functions and Robus validation

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap