What changes to the ChangeMaker program in Listing 2.3 are necessary if it also accepts coins for
Question:
What changes to the ChangeMaker program in Listing 2.3 are necessary if it also accepts coins for one dollar and half a dollar?
Listing 2.3
Transcribed Image Text:
import java.util.Scanner; public class ChangeMaker { public static void main (String[] args) { int amount, originalAmount, quarters, dimes, nickels, pennies; System.out.printin("Enter a whole number from 1 to 99."): System.out.println("I will find a combination of coins"); System.out.println("that equals that amount of change."): Scanner keyboard = new Scanner (System.in); amount = keyboard.nextInt (); originalAmount = amount; quarters = amount / 25; amount = amount % 25; dimes = amount / 10; 25 goes into 87 three times with 12 left over. 87 / 25 is 3. amount = amount % 10; nickels = amount / 5; 87 % 25 is 12. 87 cents is three quarters with 12 cents left over. amount = amount % 5; pennies = amount; System.out.println(originalAmount + " cents in coins can be given as:"); System.out.println(quarters + " quarters"); System.out.println(dimes + " dimes"); System.out.printin(nickels + " nickels and"); System.out.println(pennies + " pennies"): }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 54% (11 reviews)
Add variables int dollars halfDollars Change the prompt Systemoutprin...View the full answer
Answered By
Seema kuldeep
although I don't have an experience of teaching in a particular institute, previously I was an expert on Chegg and I have used to teach my batch mates and also my juniors.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Question Posted:
Students also viewed these Computer science questions
-
In Sec. 11.3.3 we described the problems caused by multithreaded applications closing handles in one thread while still using them in another. One possibility for fixing this would be to insert a...
-
To protect endangered sea turtle populations from further decline by reducing their incidental mortality in commercial shrimp trawling, U.S. commercial shrimp trawlers are required to use Turtle...
-
You will design and implement your own data class. The class will store data that has been read as user input from the keyboard (see Getting Input below), and provide necessary operations. As the...
-
Which model can be selected if user is involved in all the phases of Software Development Life Cycle?Prototyping Model a OWaterfall Model b OSpiral model cORapid Application Development Model . . d...
-
Reconsider Prob. 16-25. Using EES (or other) software, study the effect of varying the percent excess air during the steady-flow process from 0 to 200 percent on the temperature at which 97 percent...
-
A bond has 15 years to maturity, and annual coupon rate is 8%. If the coupons are paid semi-annually and the yield to maturity is 10%, find the price of the bond. (Assume the face value is 1000)....
-
Make a Pareto chart of the data set.
-
Angela Howard operates her own catering service. Summary financial data for July are presented in equation form as follows. Each line designated by a number indicates the effect of a transaction on...
-
Rida Incorporated is preparing its direct materials budget for the second quarter. It budgets production of 240,000 units in the second quarter and 52,500 units in the third quarter. Each unit...
-
Table 2.8 gives data on expenditure on food and total expenditure, measured in rupees, for a sample of 55 rural households from India. (In early 2000, a U.S. dollar was about 40 Indian rupees.) a....
-
Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in 5 cent increments (25, 30, 35, , 90, 95, or 100),...
-
Write a program that asks the user to enter a favorite color, a favorite food, a favorite animal, and the first name of a friend or relative. The program should then print the following two lines,...
-
a. What is the parameter of interest for this study? b. What are two possible explanations for Zwergs results of choosing the correct object 37 out of 48 times? c. Which explanation of the two...
-
Arrow Company processes a food seasoning powder through its Compounding and Packaging departments. In the Compounding Department, direct materials are added at the beginning of the process, and...
-
The 2017 financial statements of LVMH Moet Hennessey Louis Vuitton S.A. are presented in Appendix C at the end of this book. LVMH is a Paris-based holding company and one of the world's largest and...
-
Repeat Problem 10.E1, except design a packed column using 1-in. metal Pall rings. Do the calculations at the top of the column. Approximate HETP for ethanol-water is \(0.366 \mathrm{~m}\). At...
-
We are separating an ethanol-water mixture in a column operating at atmospheric pressure with a total condenser and a partial reboiler. Constant molal overflow (CMO) can be assumed, and reflux is a...
-
Corporate Social Responsibility Problem The Global Reporting Initiative (GRI) is a networkbased organization that has pioneered the development of the world's most widely used sustainability...
-
Evaluate each of the following expressions to six-figure accuracy. 0.893 -1/2
-
1. Following are information about Alhadaf Co. Cost incurred Inventory Purchases Sales Adverting expense Salary Expense Depreciation Beginning Inventory Ending Inventory Amount 118,000 350.000 90,000...
-
How can you turn a List into an array?
-
What method do you use to get an iterator for the items in a Set?
-
If you want to store a contact list with names and phone numbers, which kind of collection would work best?
-
How to solve general ledger cash balance chapter 9 assignment 5
-
On 31 July 2018, Sipho bought 1 000 ordinary shares in ABC Ltd at a cost of R2 750. On 31 December 2018 the company made a 1 for 10 bonus issue. On 31 March 2019, Sipho sold 300 shares for R800. What...
-
If you purchase a $1000 par value bond for $1065 that has a 6 3/8% coupon rate and 15 years until maturity, what will be your annual return? 5.5% 5.9% 5.7% 6.1%
Study smarter with the SolutionInn App