Problem Statement
At_least Less_than Multiplier Subtraction 100,000 117,250 25% 6,525.00 117,250 178,650 28% 10,042.50 178,650 319,100 33% 18,975.00 319,100 - 35% 25,357.00When I find out how much tax someone had to pay, I want to be able to figure out what their taxable income was. Create a class TaxTable that contains a method income that is given the taxAmount and calculates the taxable income whose tax is closest to taxAmount. This result is returned, rounded to the nearest dollar (.5 rounds up). If the taxAmount is too low to have come from the table, return -1.
Definition
- Class:
- TaxTable
- Method:
- income
- Parameters:
- int
- Returns:
- int
- Method signature:
- int income(int taxAmount)
- (be sure your method is public)
Constraints
- taxAmount will be between 0 and 1,000,000, inclusive.
- All values within 1e-6 of the taxable income corresponding to taxAmount will round to the same integer.
Examples
47025
Returns: 200000
The tax on $200,000 is 33% * 200,000 - 18975 which is 47025.
1000
Returns: -1
Anybody who has taxable income of at least $100,000 has a tax that is greater than $1000
47026
Returns: 200003
The tax on $200,000 is exactly $47,025. For each dollar above that we must pay 33 cents additional tax. So the income that results in a tax of exactly $47,026 is $200,003.0303030303.... which rounds to $200,003. Note that a return of 200002 would be incorrect, even though the tax on that amount would be 47025.66 which is close to 47026.
19001
Returns: 102104
19000
Returns: 102100
22787
Returns: 117248
22788
Returns: 117252
29967
Returns: 142891
29965
Returns: 142884
6525
Returns: -1
10043
Returns: -1
18475
Returns: 100000
18474
Returns: -1
22787
Returns: 117248
22788
Returns: 117252
999923
Returns: 2929371
787878
Returns: 2323529
0
Returns: -1
666666
Returns: 1977209
889184
Returns: 2612974
836759
Returns: 2463189
334339
Returns: 1027703
398104
Returns: 1209889
637396
Returns: 1893580
951176
Returns: 2790094
46143
Returns: 197327
284070
Returns: 884077
948256
Returns: 2781751
147452
Returns: 493740
900744
Returns: 2646003
972184
Returns: 2850117
902279
Returns: 2650389
953199
Returns: 2795874
941035
Returns: 2761120
43
Returns: -1
19826
Returns: 105404
39999
Returns: 178709
29600
Returns: 141580
4757
Returns: -1
4782
Returns: -1
86295
Returns: 319000
86304
Returns: 319027
86324
Returns: 319088
86294
Returns: 318997
22792
Returns: 117266
22789
Returns: 117255
22788
Returns: 117252
22785
Returns: 117240
22786
Returns: 117244
22792
Returns: 117266
44444
Returns: 192179
18500
Returns: 100100
40000
Returns: 178712
99999
Returns: 358160
22790
Returns: 117259
100002
Returns: 358169
1000000
Returns: 2929591
10
Returns: -1
32002
Returns: 150159
32000
Returns: 150152
18474
Returns: -1
1000
Returns: -1
86330
Returns: 319106
47025
Returns: 200000
18475
Returns: 100000
39980
Returns: 178652
47026
Returns: 200003
319100
Returns: 984163
23558
Returns: 120002
22788
Returns: 117252
18480
Returns: 100020
634643
Returns: 1885714
23000
Returns: 118009
86648
Returns: 320014
47047
Returns: 200067
22787
Returns: 117248
47044
Returns: 200058
329000
Returns: 1012449
96327
Returns: 347669
420000
Returns: 1272449