Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #define rate_pension 5
  5. #define health 1
  6. int main()
  7. {
  8. int choice, child;
  9. double income, gift, total,taxIncome, tax, remainder,temp1, temp2,temp3;
  10. char contr, insur,run;
  11. system("cls");
  12. while (9)
  13. {
  14. system("cls");
  15. printf(" Choose one of the following options: \n");
  16. printf(" 1. Tax calculator \n");
  17. printf(" 0. Exit \n");
  18. printf(" Your selection <0 -> 1>: ");
  19. scanf("%d",&choice);
  20. if ((choice!=0) && (choice!=1))
  21. {
  22. printf("*** Typing error. Please try again ***");
  23. getch();
  24. }
  25. else if (choice==0)
  26. break;
  27. else if (choice==1)
  28. {
  29. head:system("cls");
  30. printf(" Income tax Calculator \n");
  31. printf("==================================================== \n");
  32. printf("Enter personal information: \n");
  33. so1:printf("Income for the current month <in thousand VND>: ");
  34. scanf("%lf", &income);
  35. if (income<0)
  36. {
  37. printf("\nInvalid input, try again.\n");
  38. goto so1;
  39. }
  40. so2:printf("\n Pension contributions (%d%%) (y/n)? ",rate_pension,health);
  41. fflush(stdin);
  42. scanf("%c",&contr);
  43. if ((contr!='y') && (contr!='Y') && (contr!='n')&& (contr!='N'))
  44. {
  45. printf("\nInvalid input, try again.\n");
  46. goto so2;
  47. }
  48. so3:printf("\n Health insurance (%d%%) (y/n)? ",health,rate_pension);
  49. fflush(stdin);
  50. scanf("%c",&insur);
  51. if ((insur!='y') && (insur!='Y') && (insur!='n')&& (insur!='N'))
  52. {
  53. printf("\nInvalid input, try again.\n");
  54. goto so3;
  55. }
  56. so4:printf("\n Number of Dependants < 18 years old: ");
  57. scanf("%d",&child);
  58. if (child<0)
  59. {
  60. printf("\nInvalid input, try again.\n");
  61. goto so4;
  62. }
  63. so5:printf("\n Gift of charity: ");
  64. scanf("%lf",&gift);
  65. if (gift<0&&gift>=income)
  66. {
  67. printf("\nInvalid input, try again.\n");
  68. goto so5;
  69. }
  70. if ((contr=='y') || (contr=='Y'))
  71. temp1=income*rate_pension/100;
  72. else temp1=0;
  73. if ((insur=='y') || (insur=='Y'))
  74. temp2=health*income/100;
  75. else temp2=0;
  76. temp3=child*1600;
  77. total=4000 + temp1 + temp2 + temp3+gift;
  78. remainder= income - total;
  79. tax=0;
  80.  
  81. if (remainder<=5000) tax=tax + (remainder)*0.05;
  82. if (remainder>5000) tax=tax + 0.05*5000;
  83. if ((remainder>5000) && (remainder<=10000))
  84. tax=tax + 0.10*(remainder-5000);
  85. if ((remainder>5000) && (remainder>10000))
  86. tax=tax + 0.10*(10000-5000);
  87. if ((remainder>10000) && (remainder<=18000))
  88. tax=tax + 0.15*(remainder - 10000);
  89. if ((remainder>10000) && (remainder>18000))
  90. tax=tax + 0.15*(18000-10000);
  91. if ((remainder>18000) && (remainder<=32000))
  92. tax=tax + 0.2*(remainder-18000);
  93. if ((remainder>18000) && (remainder>32000))
  94. tax=tax + 0.20*(32000-18000);
  95. if ((remainder>32000) && (remainder<=52000))
  96. tax=tax + (remainder-32000)*0.25;
  97. if ((remainder>32000) && (remainder>52000))
  98. tax=tax + 0.25*(52000-32000);
  99. if ((remainder>52000) && (remainder<=80000))
  100. tax=tax + (remainder-52000)*0.3;
  101. if (remainder>80000) tax=tax + 0.35*(remainder-80000);
  102. if ((remainder>52000) && (remainder>80000))
  103. tax=tax + 0.3*(80000-52000);
  104.  
  105. printf("\nGross Income %5.1lf \n", income);
  106. printf("Deduction: \n");
  107. printf(" Personal allowance 4000.0 \n");
  108. printf(" Pension contributions %.1lf \n",temp1);
  109. printf(" Health insurance %.1lf \n",temp2);
  110. printf(" Dependants %.1f \n",temp3);
  111. printf(" Charity %.1lf \n",gift);
  112. printf(" -----------------------------------------\n");
  113. printf(" Total %.1lf \n",total);
  114. printf("Taxable Income %.1lf \n",remainder);
  115. printf("Income tax %.1lf \n",tax);
  116. printf("Net Income %.1lf \n",income-tax);
  117. so6:printf("\nAnother run (y/n)");
  118. fflush(stdin);
  119. scanf("%c",&run);
  120. if ((run!='y') && (run!='Y') && (run!='n')&& (run!='N'))
  121. {
  122. printf("\nInvalid input, try again.\n");
  123. goto so6;
  124. }
  125. else if ((run=='y') || (run=='Y'))
  126. goto head;
  127. else if ((run=='n') || (run=='N'))
  128. break;
  129. }
  130. }
  131. return(0);
  132. }
  133. /*
  134. Assignment 1 - Income tax
  135. Class ID : CS1401
  136. Student ID : HE141012
  137. Student Name : Hà Long Duy
  138. Due Date : 18/03/2019
  139. I declare that this assignment is my own work in accordance with FPT Policy.
  140. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement