|
|
Assignment 4
|
Writing short programs
Due: 11:59pm, Friday, May 2nd
Purpose: This assignment asks you to write two programs.
Write a program called InvoiceSingleItem
that does the following:
- It prompts the user for the quantity of an item being ordered and the unit cost of that
item (in dollars).
- Next, it computes the item's extended cost, which is the quantity times the unit cost.
- It then computes the invoice net amount, which, in this case, is simply the extended
cost of the one item.
- It then computes the invoice gross amount, which is the net amount plus a 5 percent tax.
- Finally, it displays the gross amount in a dialog box.
For example, if the user enters 20 for quantity and 6.00 for unit cost, the program
will compute a net invoice amount of $120.00 (which is 20 times 6.00) and a gross invoice
amount of $126.00 ($120.00 plus 5 percent). Name the file for the program InvoiceSingleItem.java
.
Write a program called InvoiceMultipleItems
that does the following:
- It repeatedly prompts the user for the quantity and unit cost of one item after another.
Each time it computes that item's extended cost and adds it to a running total of
extended costs. It will continue to do this until the user enters a quantity of 0.
- Next, it should compute the net invoice amount, which is simply the running total of the
extended costs.
- It then computes the invoice gross amount, which is the net amount plus a 5 percent tax.
- Finally, it should display the gross amount in a dialog box.
For example, if the user enters:
- 20 for quantity and 6.00 for unit cost;
- and then 10 for quantity and 5.00 for unit cost;
- and then 15 for quantity and 7.00 for unit cost;
- and finally 0 for quantity,
the program will compute a net invoice amount of $275.00 (120.00 + 50.00 + 105.00) and
a gross invoice amount of $288.75 ($275.00 plus 5 percent). Name the file for the
program InvoiceMultipleItems.java
.
What to submit: Through COL, submit a zip file containing both the InvoiceSingleItem.java
file and the InvoiceMultipleItems.java
file.