0% found this document useful (0 votes)
280 views2 pages

HMWK 02

1. The document describes an income tax table for a single resident in one state, listing tax rates from 1-6% applied to increasing income brackets. It provides instructions to create an IncomeTax project that asks the user to enter their income and displays the amount of tax due. 2. It also provides instructions to create a ShoppingCart project using a while loop to ask the user to enter prices and quantities of items, calculate a running total including 8.5% tax, and print the final total payment amount. 3. Finally, it describes a MortgageTable project that uses a for loop to display a table of monthly and total payments for a loan amount and period entered by the user, across a range

Uploaded by

david johnson
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
280 views2 pages

HMWK 02

1. The document describes an income tax table for a single resident in one state, listing tax rates from 1-6% applied to increasing income brackets. It provides instructions to create an IncomeTax project that asks the user to enter their income and displays the amount of tax due. 2. It also provides instructions to create a ShoppingCart project using a while loop to ask the user to enter prices and quantities of items, calculate a running total including 8.5% tax, and print the final total payment amount. 3. Finally, it describes a MortgageTable project that uses a for loop to display a table of monthly and total payments for a loan amount and period entered by the user, across a range

Uploaded by

david johnson
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

In one state, single residents are subject to the following income tax:

Income Amount of tax


Not over $750 1% of income
$750 - $2,250 $7.50 + 2% of amount over $750
$2,250 - $3,750 $37.50 + 3% of amount over $2,250
$3,750 - $5,250 $82.50 + 4% of amount over $3,750
$5,250 - $7,000 $142.50 + 5% of amount over $5,250
Over $7,000 $230.00 + 6% of amount over $7,000

Write a program that asks the user to enter the amount of taxable income, then displays
the tax due. Please name your project as IncomeTax.

Notes:
You need to include the above MyInput.java with your other files
in order to allow users to input numbers.

This is how the application runs:

Please enter your income:


6000
The amount of tax you should pay is: $180.00

2. Create the ShoppingCart project, use a while loop to ask user to enter the price and
units of each item (for example, 44.95, 1). After a user finishes entering the
information for one item, ask if he/she would like to continue. Calculate the total
payment at the end, including the 8.5% tax. At the end, please print out the total
payment of the shopping cart. The following example shows how the application
runs.

Please enter the price of a new item (e.g. 49.50):


44.95
Please enter the units of this item (e.g. 2):
1
Continue? (yes/no):
yes

Please enter the price of a new item (e.g. 49.50):


18.99
Please enter the units of this item (e.g. 2):
2
Continue? (yes/no):
no

Total Payment with Tax: $89.98


Thank you for your order.
Hint 1: To let user enter yes/no, use:
String choice = MyInput.readString();

Hint 2: The condition for while loop:


while (choice.equalsIgnoreCase("yes"))

3. Create a project named MortgageTable using for loop that lets the user enter the
loan amount and loan period in number of years and displays the monthly and total
payments for each interest rate starting from 5% to 8%, with an increment of 1/8.
Suppose you enter the loan amount of $750,000 for 30 years, display the table as
the following:

Please enter the loan amount:


750000
Please enter the number of years:
30
Interest Rate Monthly Payment Total Payment
------------------------------------------------------------------------------------
5.0% $4,026.16 $1,449,418.38
5.125% $4,083.65 $1,470,114.82
5.25% $4,141.53 $1,490,950.00
5.375% $4,199.78 $1,511,922.34
5.5% $4,258.42 $1,533,030.30
5.625% $4,317.42 $1,554,272.29
5.75% $4,376.80 $1,575,646.71
5.875% $4,436.53 $1,597,151.96
6.0% $4,496.63 $1,618,786.42
6.125% $4,557.08 $1,640,548.46
6.25% $4,617.88 $1,662,436.44
6.375% $4,679.02 $1,684,448.73
6.5% $4,740.51 $1,706,583.66
6.625% $4,802.33 $1,728,839.59
6.75% $4,864.49 $1,751,214.86
6.875% $4,926.97 $1,773,707.80
7.0% $4,989.77 $1,796,316.74
7.125% $5,052.89 $1,819,040.01
7.25% $5,116.32 $1,841,875.96
7.375% $5,180.06 $1,864,822.90
7.5% $5,244.11 $1,887,879.17
7.625% $5,308.45 $1,911,043.12
7.75% $5,373.09 $1,934,313.06
7.875% $5,438.02 $1,957,687.36
8.0% $5,503.23 $1,981,164.35

You might also like