Assignment Task
Exercise 1
Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value using the following formula:
and displays the future investment value using the following formula:
futureInvestmentValue =
investmentAmount * (1 + monthlyInterestRate) numberOfYears*12
For example, if you enter amount 1000, annual interest rate 3.25%, and number of years 1, the future investment value is 1032.98.
Hint: Use the Math.pow(a, b) method to compute a raised to the power of b.
Also if the future investment value is greater than or equal to 50000, add 5% of future investment value as adjustment amount otherwise subtract 3% of future investment values as adjustment amount to find the final future investment value.
Exercise 2
Suppose you want to deposit a certain amount of money into a savings account with a fixed annual interest rate. Write a program that prompts the user to enter the final account value, the annual interest rate in percent, and the number of years, and then displays the initial deposit amount. The initial deposit amount can be obtained using the following formula:
Exercise 3
The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 1 shows the rates for 2020. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.5.
2020 U.S. Federal Personal Tax Rates
Marginal Tax Rate | Single | Married Filing Jointly
or Qualified Widow(er) |
Married Filing Separately | Head of Household |
10% | $0 – $8,350 | $0 – $16,700 | $0 – $8,350 | $0 – $11,950 |
15% | $8,351– $33,950 | $16,701 – $67,900 | $8,351 – $33,950 | $11,951 – $45,500 |
25% | $33,951 – $82,250 | $67,901 – $137,050 | $33,951 – $68,525 | $45,501 – $117,450 |
28% | $82,251 – $171,550 | $137,051 – $208,850 | $68,525 – $104,425 | $117,451 – $190,200 |
33% | $171,551
– $372,950 |
$208,851 – $372,950 | $104,426 – $186,475 | $190,201 – $372,950 |
35% | $372,951+ | $372,951+ | $186,476+ | $372,951+ |
You are to write a program to compute personal income tax. Your program should prompt the user to enter the filing status and taxable income and compute the tax. Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household.
Then based on the tax, find the tax return amount based on the following criteria:
Tax | Tax return amount |
Tax>=50000 | 5% |
50000>Tax>=40000 | 8% |
40000>Tax>=20000 | 10% |
20000>Tax>=10000 | 12% |
10000>Tax | 15% |