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
How do you initiate a sprite’s actions in a scene?
irinina [24]
ummm I think sorry I don’t know I just want points lol
3 0
3 years ago
What is the difference between edge and core networks?
Dmitriy789 [7]

Answer and Explanation:

Difference between core network and edge network:

  • Core network is also known as the backbone network whereas edge network stands for enhanced data rate for global evolution
  • Core network provides the path for exchanging the information between different sub networks,whereas edge network provide information exchange between excess network and core network

6 0
3 years ago
An important goal of biosecurity training is to: Prevent laboratory accidents that could expose personnel to hazardous agents. P
Anestetic [448]

Answer:

Educate laboratory directors on their role in providing a safe working environment.

Explanation:

A lab is an abbreviation for laboratory and it can be defined as a building that is equipped with scientific equipments and apparatus, which are used for performing scientific experiments, manufacturing of chemicals and drugs, research, testing and analysis of hypothesis in order to establish a theory.

Generally, laboratory scientists, technicians, students and anyone going into a laboratory are expected to obey the rules and regulations guiding the laboratory.

Hence, an important goal of biosecurity training is to educate laboratory directors on their role in providing a safe working environment.

6 0
3 years ago
Which administrative tool can you use to check your computer's health or troubleshoot problems with the operating system or soft
Fiesta28 [93]

Answer:

performance monitor

Explanation:

7 0
3 years ago
Read 2 more answers
Which peripheral device is used to record sound?
faust18 [17]

he will need a microphone, it is a recording device.

8 0
3 years ago
Read 2 more answers
Other questions:
  • In the game of economics, which player has the role of providing goods and services
    10·1 answer
  • When CPU failed what will happen?
    10·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Write a method called printRange that accepts two integers as arguments and prints the sequence of numbers between the two argum
    6·1 answer
  • Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb
    12·1 answer
  • Only technical managers needs to know about programming, web view source code and about technology issues.
    12·1 answer
  • Which of the following statement is correct? Select one: a. Base register holds the size of a process. b. Limit register holds t
    10·1 answer
  • In Python what are the values passed into functions as input called?
    13·1 answer
  • Explaio mode of Operation of x-ray​
    15·2 answers
  • Whats with the bot spamming customer care numbers...kinda annoying when im trying to help people.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!