Search for question
Question

1. The following shows an example of tax code (this is from a number of years ago, so it probably is not

still valid).

a.

Single

Taxable income

$0 to $9,275

$9,276 to $37,650

$37,650 to $91,150

$91,150 to $190,150

$190,150 to $413,350

$413,350 to $415,050

$415,050 or more

Married Filing Jointly

Taxable income

$0 to $18,550

$18,550 to $75,300

$75,300 to $151,900

$151,900 to $231,450

$231,450 to $413,350

$413,350 to $466,950

$466,950 or more

Tax rate

10%

$927.50 plus 15% of the amount over $9,275

$5,183.75 plus 25% of the amount over $37,650

$18,558.75 plus 28% of the amount over $91,150

$46,278.75 plus 33% of the amount over $190,150

$119,934.75 plus 35% of the amount over $413,350

$120,529.75 plus 39.6% of the amount over $415,050

Tax rate

10%

$1,855.00 plus 15% of the amount over $18,550

$10,367.50 plus 25% of the amount over $75,300

$29,517.50 plus 28% of the amount over $151,900

$51,791.50 plus 33% of the amount over $231,450

$111,818.50 plus 35% of the amount over $413,350

$130,578.50 plus 39.6% of the amount over $466,950

Create a user-defined VBA function called tax(,) that outputs the tax given the

taxable income (in dollars) and status (1 for single and 2 for married filing jointly).

As an example, if a married couple earned $125,000 (taxable income), then the tax would be:

$10,367.50 +0.25*($125,000-$75,300) = $22,792.50/nworking function in Excel:

=tax(125000,2)

22792.5

If you make $75,000 in taxable income your first year working as an engineer, what will your taxes

be? Assume that you are single. Also, what percentage of your overall taxable income will you be

paying in taxes?

b. Plot tax as a function of taxable income from $0 to $500,000 for a single taxpayer. Remove any

markers and present the result as a smoothed line.

c. You overhear a very wealthy couple (married filing jointly, who you know make $500,000 a year in

taxable income) complain, "40% of what we make we have to pay back in taxes!" Yes, the money

that is earned between $466,950 and $500,000 is taxed at a nearly 40% tax rate (39.6%), but really,

how much (looking for a percentage) of their total taxable income do they have to pay in taxes?

2. The exponential function can be approximated as the following Taylor series:

e* = 1 + x +

+....

=Σ**

n!

n=0

Create a VBA function called myexp(x) that will sum the first 100 terms of the above infinite series.

A summation sign is a good indicator that you will need to use a For...Next loop.

Show a few examples and compare to the exp(x) function in Excel. Are they the same?/n3. Create a VBA function called prime(n) that outputs TRUE if n is a prime number and FALSE if n is not

a prime number. The flowchart on the next page depicts the algorithm for determining if n is prime or

not. Let's assume most of you will live another 60 years (good assumption). For the years 2023 through

2083, how many of those years are prime number years? Document in Excel.

HINT #1: The mod function in VBA will help you determine whether a number x is divisible by y (if x

Mod y is equal to zero, that means x is divisible by y with no remainder).

HINT #2: The ROUNDDOWN function in Excel will provide you with the integer part (written in the flow

chart as int) of a number. For example, int(√37) is 6 and in VBA you can use

ROUNDDOWN(SQR(37,0)), which is 6. You could also use the int function.

Fig: 1

Fig: 2

Fig: 3