w*******2 发帖数: 35 | 1 问题如下:
Write a program to create a customer's bill for a company. The company sells
only five different products: TV, VCR, Remote Controller, CD Player and
Tape Recorder. The unit prices are $400.00, $220, $35.20, $300.00 and $150.
00 respectively. The program must read the quantity of each piece of
equipment purchased from the keyboard. It then, calculates the cost of each
item, the subtotal and the total cost after an 8.25% sales tax. The input
data consists of a set of integers representing the quantities of each item
sold. These integers must be input into the program in a user-friendly way;
that is, the program must prompt the user for each quantity as shown below-
Enter the quantity of TVs sold: 2
Enter the quantity of VCRs sold: 1
Enter the quantity of remote controls sold: 4
Enter the quantity of CD players sold: 1
Enter the quantity of tape recorders sold: 2
QTY DESC PRICE TOTAL
2 Television $400.00 $800.00
1 VCR $220.00 $220.00
4 Remote Control $35.20 $140.80
1 CD Player $300.00 $300.00
2 Tape Recorder $150.00 $300.00
Subtotal: $1760.80
Tax (8.25%): $145.27
Total: $1906.07
Define constants for the unit prices and the tax rate. Use integer variables
to store the quantities for each item. Use floating-point variables to
store the total price of each item, the bill subtotal, the tax amount and
the total amount of the bill. Run your program two times with the following
data:
Set 1 -> 2 1 4 1 2
Set 2 -> 3 0 2 0 21
Format the output adequately showing the 4 columns (QTY, DESCRIPTION, UNIT
PRICE, TOTAL PRICE) in a single row. Use System.out.printf for output.
Use static functions for this problem.
该如何写代码?
求解,不剩感激 | t**c 发帖数: 480 | | U***A 发帖数: 849 | |
|