Question: CorrectChange.java When cashiers make change they first try to fit dollars into the amount you get back, then try to fit quarters (25 cent

CorrectChange.java When cashiers make change they first try to "fit" dollars into the amount you get back, then try to fit quarters (25 cent coins) into what is left over, they try to fit dimes (10 cent coins) into what is now left over, then try to fit nickels (5 cent coins) into what is left, and finally are left with a few odd cents. For example, say that your change is 163 cents: One dollar fits into 163, leaving 63 cents. Two quarters fit into 63 cents, leaving 13 cents. One dime fits into 13 cents, leaving 3 cents. No nickels are needed. Three cents are left. Your change is: 1 dollar, two quarters, one dime, and three cents. Write a program that reads how much change is due (in cents) and writes out that amount as dollars, quarters, dimes, nickels, and pennies. Use integers for all variables and all arithmetic. If you are stuck, do an example problem with paper and pencil. Output should look like this 1 How many cents is due: 163 2 Your change is 1 dollar, 2 quarter, 1 dime, nickel, and 3 penny. D 1 2 3 Run CorrectChange.java 4 5 } public class Correct Change public static void main (String[] args) { Online (1) } CONSOLE SHELL Check Answer K2008889 Ho Reset to Template Recent Submissions ~ Open Desktop 0 / 100 Points
Step by Step Solution
There are 3 Steps involved in it
The code provided calculates the minimum number of dollarsquartersdimesnickelsand pennies needed to make a given amount of changeHeres how it works The program first declares an integer variable amoun... View full answer
Get step-by-step solutions from verified subject matter experts
