Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #define rate_pension 5
- #define health 1
- int main()
- {
- int choice, child;
- double income, gift, total,taxIncome, tax, remainder,temp1, temp2,temp3;
- char contr, insur,run;
- system("cls");
- while (9)
- {
- system("cls");
- printf(" Choose one of the following options: \n");
- printf(" 1. Tax calculator \n");
- printf(" 0. Exit \n");
- printf(" Your selection <0 -> 1>: ");
- scanf("%d",&choice);
- if ((choice!=0) && (choice!=1))
- {
- printf("*** Typing error. Please try again ***");
- getch();
- }
- else if (choice==0)
- break;
- else if (choice==1)
- {
- head:system("cls");
- printf(" Income tax Calculator \n");
- printf("==================================================== \n");
- printf("Enter personal information: \n");
- so1:printf("Income for the current month <in thousand VND>: ");
- scanf("%lf", &income);
- if (income<0)
- {
- printf("\nInvalid input, try again.\n");
- goto so1;
- }
- so2:printf("\n Pension contributions (%d%%) (y/n)? ",rate_pension,health);
- fflush(stdin);
- scanf("%c",&contr);
- if ((contr!='y') && (contr!='Y') && (contr!='n')&& (contr!='N'))
- {
- printf("\nInvalid input, try again.\n");
- goto so2;
- }
- so3:printf("\n Health insurance (%d%%) (y/n)? ",health,rate_pension);
- fflush(stdin);
- scanf("%c",&insur);
- if ((insur!='y') && (insur!='Y') && (insur!='n')&& (insur!='N'))
- {
- printf("\nInvalid input, try again.\n");
- goto so3;
- }
- so4:printf("\n Number of Dependants < 18 years old: ");
- scanf("%d",&child);
- if (child<0)
- {
- printf("\nInvalid input, try again.\n");
- goto so4;
- }
- so5:printf("\n Gift of charity: ");
- scanf("%lf",&gift);
- if (gift<0&&gift>=income)
- {
- printf("\nInvalid input, try again.\n");
- goto so5;
- }
- if ((contr=='y') || (contr=='Y'))
- temp1=income*rate_pension/100;
- else temp1=0;
- if ((insur=='y') || (insur=='Y'))
- temp2=health*income/100;
- else temp2=0;
- temp3=child*1600;
- total=4000 + temp1 + temp2 + temp3+gift;
- remainder= income - total;
- tax=0;
- if (remainder<=5000) tax=tax + (remainder)*0.05;
- if (remainder>5000) tax=tax + 0.05*5000;
- if ((remainder>5000) && (remainder<=10000))
- tax=tax + 0.10*(remainder-5000);
- if ((remainder>5000) && (remainder>10000))
- tax=tax + 0.10*(10000-5000);
- if ((remainder>10000) && (remainder<=18000))
- tax=tax + 0.15*(remainder - 10000);
- if ((remainder>10000) && (remainder>18000))
- tax=tax + 0.15*(18000-10000);
- if ((remainder>18000) && (remainder<=32000))
- tax=tax + 0.2*(remainder-18000);
- if ((remainder>18000) && (remainder>32000))
- tax=tax + 0.20*(32000-18000);
- if ((remainder>32000) && (remainder<=52000))
- tax=tax + (remainder-32000)*0.25;
- if ((remainder>32000) && (remainder>52000))
- tax=tax + 0.25*(52000-32000);
- if ((remainder>52000) && (remainder<=80000))
- tax=tax + (remainder-52000)*0.3;
- if (remainder>80000) tax=tax + 0.35*(remainder-80000);
- if ((remainder>52000) && (remainder>80000))
- tax=tax + 0.3*(80000-52000);
- printf("\nGross Income %5.1lf \n", income);
- printf("Deduction: \n");
- printf(" Personal allowance 4000.0 \n");
- printf(" Pension contributions %.1lf \n",temp1);
- printf(" Health insurance %.1lf \n",temp2);
- printf(" Dependants %.1f \n",temp3);
- printf(" Charity %.1lf \n",gift);
- printf(" -----------------------------------------\n");
- printf(" Total %.1lf \n",total);
- printf("Taxable Income %.1lf \n",remainder);
- printf("Income tax %.1lf \n",tax);
- printf("Net Income %.1lf \n",income-tax);
- so6:printf("\nAnother run (y/n)");
- fflush(stdin);
- scanf("%c",&run);
- if ((run!='y') && (run!='Y') && (run!='n')&& (run!='N'))
- {
- printf("\nInvalid input, try again.\n");
- goto so6;
- }
- else if ((run=='y') || (run=='Y'))
- goto head;
- else if ((run=='n') || (run=='N'))
- break;
- }
- }
- return(0);
- }
- /*
- Assignment 1 - Income tax
- Class ID : CS1401
- Student ID : HE141012
- Student Name : Hà Long Duy
- Due Date : 18/03/2019
- I declare that this assignment is my own work in accordance with FPT Policy.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement