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...
-
If you have taken a chemistry or physics class, then you are probably familiar with Boyles law: for gas in a confined space kept at a constant temperature, pressure times volume is a constant (in...
-
Given the following data from a randomized block design, (a) Decompose each observation \(y_{i j}\) as \[\begin{aligned} y_{i j}= & \bar{y}_{\bullet}+\left(\bar{y}_{\bullet \bullet}-\bar{y}_{\bullet...
-
Over-the-Rhine Company used 5,500 board feet of raw materials with a standard cost of $6.00 per board foot to make 400 tables. The companys standard is 14 board feet per table. Calculate the companys...
-
Write a Go program that processes a list of messages using a concurrent function. A main function passes the list of messages to a go function that encrypts each message and send each resulting...
-
Which of the graphs in Fig. Q25.12 best illustrates the current I in a real resistor as a function of the potential difference V across it? Explain. Figure Q25.12 (a) (b) (c) (d)
-
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,...
-
Two parallel wires are 5.00 cm apart and carry currents in opposite directions, as shown in Fig. Find the magnitude and direction of the magnetic field at point P due to two 1.50-mm segments of wire...
-
Take two countries of your choice and compare their country risk profiles.
-
What could be the benefits of positioning oneself as a standardized global niche differentiator? What kind of competitive advantages does this require?
-
Can you give examples of a hub in Africa, an emerging giant in Latin America and a resource-rich country in Eastern Europe?
-
Based on your personal experience, give concrete examples of the reach and richness capabilities of the internet.
-
Brazil, one of the worlds largest emerging markets with the ninth largest economy, has a population of 208 million and GDP of $1.8 trillion.97 In 2014, a federal police superintendent in Brazil began...
-
Marriott International Inc. (MAR) and Hilton Wordwide Holdings Inc. (HLT) operate hotels worldwide. The following data (in millions) were adapted from recent financial statements of Marriott and...
-
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?
-
Skysong needs to calculate the company's expected cash receipts for the upcoming month to determine whether additional financing is needed. Typically, the company's sales consist of 40% cash sales...
-
The value of NSE index is 1140. The continously compunded risk free rate is 4.6% amnd continous dividend yield is 2.1%. Calculate the no arbitrage price for a 140 day forward contract on the index
-
Explain why MNCs such as Coca Cola and PepsiCo, Inc., still have numerous opportunities for international expansion. Explain briefly
Study smarter with the SolutionInn App