You are on page 1of 2

Al Imam Mohammad Ibn Saud Islamic University

College of Computer and Information Sciences


Computer Science Department

CS 150 – Introduction to Computer Programming


CS140 – Computer Programming 1
Lab Exam I
Exam starting time: 24/02/2021 12:00 pm,
Submission deadline time: 25/02/2021 02:00 pm,
Evaluation starting time: 25/02/2021, 04:00 pm,
15 Marks
Instructions:
1. Answer the question in one file.
2. Write your name, section, and student ID, at the beginning of the file.
3. Make sure you submit your solution before 2:00 pm 25/02/2021.
4. Make sure you attend the online evaluation by using the link sent to you by the course
instructor.
5. Be prepared to share your computer screen and to use your microphone during the
evaluation discussion.
6. By submitting your solution, you affirm that you did not give or receive any
unauthorized help on this exam, and that all work is done by yourself.

Question: To be answered in (90) Minutes / 15 Marks

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

Imam University | CCIS | Doc. No. 006-02-20170316


Al Imam Mohammad Ibn Saud Islamic University
College of Computer and Information Sciences
Computer Science Department

Running Example 1:
..

Running Example 2:
..

Running Example 3:
..

Imam University | CCIS | Doc. No. 006-02-20170316

You might also like