Skip to content

Case Study 1

Zhamri Che Ani edited this page Oct 30, 2023 · 1 revision

Instruction

Below are the prices of the mineral waters.

Bottle(s) Price
< 10 RM 1.00/bottle
10 RM 8.00
24 RM 12.00

Based on the table, write a Java program to:

  1. calculate how many bottles can be bought for RM150? The amount must be input from the keyboard.
  2. calculate the price for 70 bottles? The quantity of the bottles must be input from the keyboard.
  3. display the detail calculation.

Example of the output

1. Enter Amount
2. Enter Bottle
0. Exit
1
Enter amount (RM): 50
Amount RM: 50.0
--------------------------------------
4 set24 (96 bottles) -> RM48.0
0 set10 (0 bottles) -> RM0.0
2 bottle(s) -> RM2.0
Total: RM50.0
Balance: RM0.0
Total Bottle(s): 98
--------------------------------------
Please choose an option:
1. Enter Amount
2. Enter Bottle
0. Exit
2
Enter number of bottles: 70
Quantity (bottles): 70
--------------------------------------
2 set24 (48 bottles) -> RM24.0
2 set10 (20 bottles) -> RM16.0
2 bottle(s) -> RM2.0
Total: RM42.0
--------------------------------------
Clone this wiki locally