CorrectChange.java When cashiers make change they first try to fit dollars into the amount you get...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
The instruction to convert 'A' to 'a' is: Select one: a. or al, 0000010b b. or al, 00100000b or al, 00100100b d. or al, 00010000b e. or al, 01100000b
-
Fill in the blanks: Shake something to and fro and you're measuring its ________. Lift it against gravity and you're measuring its ________.
-
Compute the area of the shaded region in two different ways: (a) By using simple geometric formulas; (b) By applying Theorem I. Theorem I: Area under a Graph If f(x) is a continuous nonnegative...
-
Using only the factor formulas given in Table 2.6, derive Equation 7.6 starting with Equation 7.3. TABLE 2.6 Summary of Discrete Compounding Interest Factors. To Find Given Factor Symbol Name P F...
-
Spencer Enterprises is attempting to choose among a series of new investment alternatives. The potential investment alternatives, the net present value of the future stream of returns, the capital...
-
What are some ways to determine which database management system will work best for a given project? What are some best practices or industry-accepted criteria for matching a given database...
-
A carpet manufacturer is interested in locating a plant so as to minimize total distance traveled to four distribution centers The xy coordinates of the four distribution centers are found in the...
-
Assume transaction data from three comparable properties are used in valuing the subject property. The amount of the adjustment for each item has been estimated by the appraiser and is shown in the...
-
Consider risk measures on the following 3 large cap stocks: Stock Beta (B) Berkshire Hathaway (BRK) 0.69 Apple (APPL) 1.15 Microsoft (MSFT) 1.28 Standard Deviation (6) 23.50% 27.00% 25.50% The...
-
You are a financial advisor and a portfolio manager. You are going to help your client, Anna, to find an optimal portfolio for her retirement (a complete portfolio). After due diligence, you have...
-
Answer the following questions. a) State the normal form of the above table. Explain your answer with reasons. (3 marks) b) Convert the table into a relational schema. Identify the primary key(s) and...
-
Calculate the reaction forces in the supports of the system shown in the figure. F-14 kN, F-18 kN, M-22 kNm, the intensities of the distributed forces are q-8 kN/m, q2-4 kN/m; a-3 m, b-4 m, c-0.5 m,...
-
Briefly describe, how can a carbohydrate provide energy to the cell? and provide an example.
-
Element compound homogeneous mixture (heterogeneous mixture) 4) A piece of gold has a mass of 49.75 g. What should the volume be if it is pure gold? Gold has a density of 19.3 g/cm (3 points) D=m/v...
-
1. What is the NFPA diamond and why is it important? 2. Go to Wikipedia and search ethylene oxide to find the NFPA diamond numbers. 3. Draw the NFPA diamond for the chemicals propylene, isohexane,...
-
While on his way home from a concert by Ann Arbors own Bob Seger at Pine Knob, during his visit to Michigan, world famous Inspector Sgt. Nigel Ambercromby was called in from Scotland Yard when the...
-
Consider the RTD function E(t)={AB(t0t)30}for 0t <2t0for t>2t0 a. Sketch E(t) and F(t). b. Calculate tm and 2. c. What are the restrictions (if any) on A, B, and t0?
-
A store managers job is to keep total wages to no more than 30% of sales and to maintain the fuel bill and the supply bill at about 9% of sales each. Managers can also directly affect sales by...
-
Is there another incentive plan you think would work better for the pressers? Describe it.
-
What is merit pay? Do you think its a good idea to award employees merit raises? Why or why not?
Study smarter with the SolutionInn App