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: 42% (7 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...
-
The reflector of a flashlight is in the shape of a parabolic surface. The casting has a diameter of 8 inches and a depth of 1 inch. How far from the vertex should the light bulb be placed?
-
List and discuss the major information security and privacy threats to organizations.
-
Suppose Stenback Valley is deciding whether to purchase new accounting software. The payback for the $30,050 software package is five years, and the softwares expected life is seven years. Stenback...
-
Assume the discount rate is 10%. An FI originates a pool of real estate loans worth $2 million with maturities of 5 years and paying interest rates of 10% APR per year. Calculate the yearly payments...
-
Suppose the average checkout tab at a large supermarket is $65.12, with a standard deviation of $21.45. Twenty-three percent of the time when a random sample of 45 customer tabs is examined, the...
-
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,...
-
Eastern Corporation, the investment banking company, often has extra cash to invest. Suppose Eastern buys 1,000 shares of Dream, Inc., stock at $57 per share. Assume Eastern expects to hold the Dream...
-
This summer Paige's town will be hosting a series of 9 concerts. There are two types of seats at the concerts, which are priced at $29.50 and $43.00. Paige would like to attend at least 5 concerts...
-
The dividend discount model (DDM) is a quantitative method of valuing a company's stock price. Answer all the following parts of the question. (Total marks: 24) a. Explain the logic of dividend...
-
A laboratory has won a 15,000 research grant to be used to purchase equipment that will aid the research of the eight researchers who use the facility. From discussion with the researchers, the...
-
Jessica is planning to paint her room. It measures 11 feet by 13 feet and has 8 -foot ceilings. One long wall and one short wall each have a window that measures 3 feet by 4 feet. One short wall has...
-
a) A company just paid a dividend of Do = $5.00 on its preferred stock. The dividend amount will remain constant. The discount rate (i.e., market capitalization rate) of the company is k = 8%. What...
-
The following are the closing stock prices for a pharmaceutical firm over the past two weeks. a. Specify the competing hypotheses to determine whether the median stock price is greater than $61.25....
-
What are the risks and liability factors in an audit? What are the implications to the auditor? What are the implications to the organization? How can the auditor mitigate these risks and liability...
-
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?
-
Discuss with examples about financial innovation& how it develops banking industry?
-
Elaborate with real world examples about different financial markets that contributed towards growth of financial sector?
-
The following statement of financial position is for the partnership of Able, Brown, and Crown at November 1, 2018. Assets Liabilities Cash $ 20,000 Accounts payable $ 50,000 Other assets 180,000...
Study smarter with the SolutionInn App