Professional Documents
Culture Documents
ملف اختبار اللاب 1
ملف اختبار اللاب 1
Write a Java program that help JAVA CAFÉ to calculate and display the bill to the customer.
It receives the number of coffee cups, and donuts that the user ordered and returns bill total.
• It should check first if the Café has enough cups and/or donuts before initiating and
order. If the Café has inventory shortage, then it prints “Error: not enough cups and/or
donuts” and cancel the order.
• If the customer is a student, he will get 10% discount.
• coffeePrice=7.5, and donutPrice=4.25 represent price of items.
• coffeeTotQty=10, and donutTotQty=10 represent quantities cups and donuts in
inventory.
• subtotal is bill total before discount.
• discountedPrice is the amount discounted.
• total is total of final bill.
The displayed itemized bill as following (Hint: use printf and escaped character to align the
printing):
-------------------------------------------------------------
Item Quantity Price
Coffee 4 30.00
Donuts 3 25.50
-------------------------------------------------------------
Sub Total 55.50
Discount (-10%) 5.50
-------------------------------------------------------------
Total 50.0
Running Example 1:
..
Running Example 2:
..
Running Example 3:
..