Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Compare and contrast a network-based IPS, and a host-based IPS.

Answered: 1 week ago