Question: Please execute this program in Java please and hank you! The Change Calculator: You are off to the candy store with a $5 bill to
Please execute this program in Java please and hank you!
The Change Calculator: You are off to the candy store with a $5 bill to buy some candies. Write a program called ChangeCalculator that allows you to enter the total cost of the candies that you are buying (i.e., use the Scanner class) in cents (i.e., 127 cents is $1.27). The program should then tell you how many dollars, quarters, dimes, nickels and pennies that you should get as your change (assuming that you always pay with a $5 bill). Your program should return the least amount of coins possible. All your calculations should be in terms of cents so that you can use just int variables. Please handle exceptions nicely in your program. Your program should have nice-looking output as follows: Enter the cost of the candies (in cents): 127 The change from $5.00 for $1.27 of candies is: 3 dollar(s) 2 quarter(s) 2 dime(s) 0 nickel(s) 3 pennie(s) Notice that amount entered is an integer (i.e., total cents) but the output statement displays the cost as a double (i.e., dollars). Test your code with the following costs: 0, 25, 100, 101, 107, 150, 201, 235, 400, 498, 499, 500, 700
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
