"C and Pointers" chapter 8th programming Exercises 2nd:
1 /*2 * * Calculation of income tax for U.S. citizens in 19953 */4 5#include <stdio.h>6#include <float.h>//The header file contains the largest number that the double type can represent Dbl_max7 8 DoubleSingle_tax (Doubleincome);9 Ten /* One * * Divide the range in the table into arrays A */ - Static Double ConstIncome_limit[] = {0,23350,56550,117950,256500, Dbl_max}; - Static Double ConstBase_tax[] = {0,3502.5,12798.5,31832.5,81710.5 }; the Static Double ConstPercentage[] = {0.15,0.28,0.31,0.36,0.396 }; - - intMain () - { + Doubleincome; -scanf"%LF", &income); +printf"%LF", Single_tax (income)); A at return 0; - } - - /* - * * function, calculate the corresponding income corresponding to the tax amount - * * The data type of function prototype in the title is float, but float is not accurate in the test in */ - Double toSingle_tax (Doubleincome) + { - intrange; the DoubleTax ; * $ /*Panax Notoginseng * * Get the calculation interval corresponding to the tax amount - */ the for(range =1; Income > income_limit[Range]; ++range) + ; ARange--; the + /* - * * Tax calculation formula $ */ $Tax = base_tax[Range] + (income-income_limit[Range]) *percentage[Range]; - - returnTax ; the}
Calculate 1995 US personal income tax