1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kondor19780726 [428]
4 years ago
14

Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l

ine. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is:
Computers and Technology
1 answer:
Paraphin [41]4 years ago
6 0
I'm assuming Java, but if you need a different language, it shouldn't be too hard to transcribe.

public void toCoins(int totalChange) {
int[] coins = new int[5] //array of coin counts
int[] values = new int[]{100, 25, 10, 5, 1}
String[] singular = new String[]{"dollar", "quarter", "dime", "nickel", "penny"};
String[] plural = new String[]{"dollars", "quarters", "dimes", "nickels", "pennies"};
for(int i = 0; i < 5; I++) {
while(totalChange > values[i]) {
totalChange -= values[i];
coins[i]++;
}
}
for(int i = 0; i < 5; i++) {
if(coins[i] == 1) System.out.println("1 " + singular[i]);
else if(coins[i] > 1) System.out.println(coins[i] + " " + plural[I]);
}


You might be interested in
The contents of an array of type ______ can be displayed with the cout operator (without specifying an element). - 1 point(s)
xxMikexx [17]
The contents of an array of type char can be displayed with the cout operator.  <span>Array declarations </span>must<span> contain the information about the size of the array. It is possible to leave the size out of the [ ] in the declaration </span>as long as<span> you initialize the array inline, in which case the array is made just large enough to capture the initialized data. </span>  
5 0
3 years ago
Which partitioning method must you use for a 4-tb hard drive?
kogti [31]
Convert the MBR to GPT disk is a way to solve the problem.
4 0
3 years ago
I really need help with this question, I can’t fail this please :) tysm
Maurinko [17]

Answer:

i think its the third one, i hope this helps

Explanation:

4 0
4 years ago
What is a sign that content is
Sidana [21]
D. All of the above
7 0
4 years ago
Read 2 more answers
Does Kennesaw State University have any computing ethical policy for computer usage? If so - what is it?
Svet_ta [14]

Answer:

The answer to the questions: Does Kennesaw State University have any computing ethical policy for computer usage? If so - what is it? Would be as follows:

1. Yes, Kennesaw State University, a university in Georgia, does have a computing ethical policy that regulates the proper use of the facilities and computing services within the facilities of the university and the use of computing equipment that belongs to the university. This policy is known as the KSU Computer Usage Policy.

2. As said before this policy establishes that the use of computing services are not the right of a person, but rather a privilege afforded to the students, faculty and other people who are present in the university and who may need to use its computing services. The use of the computing services would be whitin this policy as long as it stays inside the delimitations established by federal, state and University policies.

Explanation:

7 0
4 years ago
Other questions:
  • Danny is editing the text content of a single page on a website he created a year ago. What part of the tag would he have to upd
    11·1 answer
  • Casey Griggs is a very capable computer engineer. Recently, he noticed a problem that computer engineers have, and thought of a
    13·1 answer
  • With which feature or menu option of a word processing program can you make an image like this ?
    15·2 answers
  • Which of the following is a device that plugs in a usb port on the computer or mobile device and contains multiple usb ports?
    9·1 answer
  • Clicking this would navigate among different worksheets
    14·1 answer
  • Assume that two arrays are parallel. Assume the first array contains a person's id number and the second contains his or her age
    5·1 answer
  • 2. When a process is "listed" in a queue, what information is actually stored in the list in memory?
    14·1 answer
  • How many times will an infinite loop repeat?
    9·1 answer
  • How to enhance the video to full screen in filmora
    15·1 answer
  • Internet speed test, why does it take some time to get maximum speed
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!