Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<time.h>
  4. float taxIsrael(float salary, float taxAllowance);
  5. int main(){
  6. float salary = 58000;
  7. float taxAllowance = 2.25;
  8. float tax = taxIsrael (salary, taxAllowance);
  9. printf("tax = %f\n", tax);
  10. return 0;
  11. }
  12.  
  13. float taxIsrael(float salary, float taxAllowance){
  14. int arr1[8] = {0, 6310, 9050, 14530, 20200, 42030, 54130, 2000000000};
  15. float arr2[8] = {0, 0.1, 0.14, 0.2, 0.31, 0.35, 0.47, 0.5};
  16. int i;
  17. float tax = -(2.25 * 216);
  18. for (i = 1; (arr1[i] + 1) < salary || (arr1[i] + 1) > salary; i++){
  19. if (salary > arr1[i]){
  20. tax += (arr1[i] - arr1[i - 1]) * arr2[i];
  21. }else {
  22. tax +=(salary - arr1[i - 1]) * arr2[i];
  23. break;
  24. }
  25. }
  26. return tax > 0 ? tax : 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement