Statistics

Problem Statement for "TaxTable"

Problem Statement

For those who file jointly and have a taxable income of at least $100,000 the tax for 2004 is calculated from the following table. To calculate your tax, you find the appropriate bracket for your taxable income, multiply your taxable income by the multiplier, and then subtract the subtraction value.


    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.00

When 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

  1. 47025

    Returns: 200000

    The tax on $200,000 is 33% * 200,000 - 18975 which is 47025.

  2. 1000

    Returns: -1

    Anybody who has taxable income of at least $100,000 has a tax that is greater than $1000

  3. 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.

  4. 19001

    Returns: 102104

  5. 19000

    Returns: 102100

  6. 22787

    Returns: 117248

  7. 22788

    Returns: 117252

  8. 29967

    Returns: 142891

  9. 29965

    Returns: 142884

  10. 6525

    Returns: -1

  11. 10043

    Returns: -1

  12. 18475

    Returns: 100000

  13. 18474

    Returns: -1

  14. 22787

    Returns: 117248

  15. 22788

    Returns: 117252

  16. 999923

    Returns: 2929371

  17. 787878

    Returns: 2323529

  18. 0

    Returns: -1

  19. 666666

    Returns: 1977209

  20. 889184

    Returns: 2612974

  21. 836759

    Returns: 2463189

  22. 334339

    Returns: 1027703

  23. 398104

    Returns: 1209889

  24. 637396

    Returns: 1893580

  25. 951176

    Returns: 2790094

  26. 46143

    Returns: 197327

  27. 284070

    Returns: 884077

  28. 948256

    Returns: 2781751

  29. 147452

    Returns: 493740

  30. 900744

    Returns: 2646003

  31. 972184

    Returns: 2850117

  32. 902279

    Returns: 2650389

  33. 953199

    Returns: 2795874

  34. 941035

    Returns: 2761120

  35. 43

    Returns: -1

  36. 19826

    Returns: 105404

  37. 39999

    Returns: 178709

  38. 29600

    Returns: 141580

  39. 4757

    Returns: -1

  40. 4782

    Returns: -1

  41. 86295

    Returns: 319000

  42. 86304

    Returns: 319027

  43. 86324

    Returns: 319088

  44. 86294

    Returns: 318997

  45. 22792

    Returns: 117266

  46. 22789

    Returns: 117255

  47. 22788

    Returns: 117252

  48. 22785

    Returns: 117240

  49. 22786

    Returns: 117244

  50. 22792

    Returns: 117266

  51. 44444

    Returns: 192179

  52. 18500

    Returns: 100100

  53. 40000

    Returns: 178712

  54. 99999

    Returns: 358160

  55. 22790

    Returns: 117259

  56. 100002

    Returns: 358169

  57. 1000000

    Returns: 2929591

  58. 10

    Returns: -1

  59. 32002

    Returns: 150159

  60. 32000

    Returns: 150152

  61. 18474

    Returns: -1

  62. 1000

    Returns: -1

  63. 86330

    Returns: 319106

  64. 47025

    Returns: 200000

  65. 18475

    Returns: 100000

  66. 39980

    Returns: 178652

  67. 47026

    Returns: 200003

  68. 319100

    Returns: 984163

  69. 23558

    Returns: 120002

  70. 22788

    Returns: 117252

  71. 18480

    Returns: 100020

  72. 634643

    Returns: 1885714

  73. 23000

    Returns: 118009

  74. 86648

    Returns: 320014

  75. 47047

    Returns: 200067

  76. 22787

    Returns: 117248

  77. 47044

    Returns: 200058

  78. 329000

    Returns: 1012449

  79. 96327

    Returns: 347669

  80. 420000

    Returns: 1272449


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: