$34.99
Introduction to Java programming – Additional Exercises
1.The video game machines at your local arcade output coupons according to how well you play the game. You can redeem 10 coupons for a candy bar or 3 coupons for a gumball. You prefer candy bars to gumballs. Write a Java program that reads the number of coupons you have and outputs how many candy bars and gumballs you can get if you spend all of your coupons on candy bars first, and any remaining coupons on gumballs. [Ref: Pages 86-87, Chapter 1 of Absolute Java 6th Edition].
A sample interaction is given as follows (text in bold indicates user input):
How many coupons do you have: 14
With 14 coupon(s) you can get 1 candy bar(s) and 1 gumball(s).
This will leave you with 1 coupon(s).
2.You need to design a feature in a Point-of-Sale (POS) that displays the denomination of an input amount. The available denominations are of $50, $20, $10, $5, $2, $1, $0.50, $0.20, $0.10, $0.05. Write a Java a program that asks the cashier the amount of change that is to be given to the customer and then displays
Page 1 of 2
the break-down of the change in descending order of denomination. That is, calculate how many $50 notes are required, then $20, and so on. A sample interaction is a follows:
Please enter the change (without $): 165.55
Please give the customer:
$50 3
$20 0
$10 1
$5 1
$2 0
$1 0
50c 1
20c 0
10c 0
5c 1
Page 2 of 2