Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use DrRacket One of the big ideas we'll encounter again and again this term is that we can take the value returned by one function

Use DrRacket

One of the big ideas we'll encounter again and again this term is that we can take the value returned by one function and use it as an argument to another function. Let's try it with an example.

Assume that a person's income tax is based on their annual income, their tax bracket (a percentage), and the number of dependents they claim (a person may claim 0 or more dependents). The amount of income tax owed is calculated by multiplying a person's income by their tax bracket, then deducting $1000 for every dependent claimed. For example, if a taxpayer is in the 25% tax bracket and they claim 3 dependents, that person's income tax will be calculated by multiplying their annual income by 0.25, then subtracting $3000. If the calculation results in a negative number, a value of 0 should be produced.

A person's tax bracket is based on that person's annual income and marital status (either single or married). Here are the tax brackets for a single person:

Income Bracket
$0 - $14,999 10%
$15,000 - $49,999 20%
$50,000 - $99,999 25%
$100,000 or more 35%

and here are the brackets for a married person:

Income Bracket
$0 - $31,999 10%
$32,000 - $129,999 20%
$130,000 - $224,999 25%
$225,000 or more 35%

Do the following:

  • (a) Develop a function named bracket that consumes a person's annual income and their marital status (a boolean that's true if the person is single and false if they're married), and produces a percentage (either 0.10, 0.20, 0.25, or 0.35, as described above).

  • (b) Develop a function named tax that consumes a person's annual income, their marital status, and the number of dependents, and produces the amount of income tax owed by that person. The tax function must call the bracket function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. How has e-commerce transformed marketing?

Answered: 1 week ago