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]
3 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]3 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
Look at the following Python code:
aliya0001 [1]

Ump will be assigned to word2

word1[0:3] gets all of the letters from index 0 to index 3 exclusive (that means index 3 is not included)

4 0
3 years ago
"Random Bars" is considered to be a Transition style<br> O True<br> O False
Vesnalui [34]
True….hope it helps love
8 0
2 years ago
a uniform density sheet of metal is cut into a shape of an isosceles triangle, which is oriented with the base at the bottom and
Cloud [144]

The horizontal center of mass will be located at the horizontal center of mass will be located on the center line. This is further explained below.

<h3>What is Location?</h3>

Generally, a location or place that is inhabited, open for occupation or distinguished by some distinctive feature: situation The setting of the property contributes significantly to its overall allure.

In conclusion, The center line will serve as the location for the horizontal center of mass, which will be found at the same location as the center line.

Read more about Location

brainly.com/question/11718756

#SPJ1

6 0
2 years ago
How to charge your phone quickly
stepladder [879]
I found out that putting your phone on airplane mode will charge it faster
4 0
3 years ago
Read 2 more answers
You are a network administrator. Your company recently approved of employees working from home one day a week and the use of emp
Orlov [11]

Answer:

To establish the BYOD policy is the correct answer to the following question.

Explanation:

<u>Implementation of the BYOD(Bring Your Own Device)</u>:

  1. Firstly, set you objectives and establish it.
  2. Then, you have to decide and tell your employees that what types of devices are only allowed in your organization.
  3. Then, establish your security policies related to the BYOD policy.
  4. Then, give good training by you or by the IT professionals to your employees.
  5. Finally, if the employee are leaving your organization then, you have to remove those employees from the BYOD policy by which they cannot access your company's informations.
8 0
3 years ago
Other questions:
  • Waterpower was first harvested by ancient societies using
    5·1 answer
  • An IT firm came across a startup company that offers a new system of computer storage. It is currently in the experimental phase
    11·1 answer
  • why is there a need of properly interpreting teacher's/manufacturer's specifications before operating any food processing equipm
    9·1 answer
  • Why might you complete a 1040 instead of a <br> 1040ez
    11·2 answers
  • An equation that performs a calculation is a formula. True or false quest
    9·1 answer
  • Want to.learn about computers​
    9·1 answer
  • The word __________ refers to the numbers, words, or more generally, any collection of symbols that is manipulated by a program.
    7·1 answer
  • Which person would be the best fit for a career in the Information Technology field?
    6·2 answers
  • When the CPU performs the work described in the commands,
    11·1 answer
  • Write a program that accepts the lengths of three sides of a triangle as inputs. the program output should indicate whether or n
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!