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
Provide an example of a closed‐end credit account that Caroline has.
Usimov [2.4K]

<u>Explanation:</u>

Closed end credit is a loan for a stated amount that must be repaid in full by a certain date. Closed end credit has a set payment amount every month.The government and banks can limit the interest rates and fees that credit card companies can impose.


<u>Example:</u>

An example of closed end credit is a car loan.

5 0
3 years ago
Keyshia adds an image of a triple beam balance and a
vredina [299]

Answer:

select all images

Go to the pictures tool format tab

Choose the arrange group

Choose the group Option

Explanation:

7 0
3 years ago
How does one decide which businesses to invest in.
GREYUIT [131]
As you consider your options, here are seven things you should know about a company before you decide to invest:
Earnings Growth. Check the net gain in income that a company has over time. ...
Stability. ...
Relative Strength in Industry. ...
Debt-to-Equity Ratio. ...
Price-to-Earnings Ratio. ...
Management. ...
Dividends.
3 0
3 years ago
If a file is opened for reading and the file does not exist,what action is taken?
worty [1.4K]

Answer:

C)An error message is issued.

Explanation:

If we try to open a file for reading when that file does not exist, we will get an error message.

For example, in Java we will encounter a FileNotFoundException as in the code below:

       try {

           FileInputStream fis = new FileInputStream("myFile.txt");

           DataInputStream dis = new DataInputStream(fis);

           BufferedReader br = new BufferedReader(new InputStreamReader(dis));

           String str = null;

           while ((str = br.readLine()) != null) {

               System.err.println(str);

           }

       } catch (FileNotFoundException e) {

           e.printStackTrace();

       }

If the file myFile.txt does not exist we can expect to see an exception stack trace corresponding to FileNotFoundException.

8 0
4 years ago
The java compiler is able to find all programmer errors.
Troyanec [42]
No compiler can do that. Maybe with AI, but that's beyond the scope of a compiler.
5 0
4 years ago
Other questions:
  • Which is NOT a way the network operating sys-
    6·1 answer
  • Tyler trades in a car worth $5,000 (wholesale) on a new $15,000 car, but still owes $7,000 on his old car. How much will he owe
    12·1 answer
  • Select the correct answer. Which sentence best describe an effective management strategy? A. Conceal game-related clippings prio
    12·2 answers
  • Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual. wh
    5·2 answers
  • How do i end my current plan that i never signed up for, the basic one it charged me $24
    11·2 answers
  • A typical setup for a ____ network would include computer users sharing a single internet connection.
    15·1 answer
  • In recent years, the amount of time people spend using electronic devices has sharply increased. What are the benefits and downs
    7·1 answer
  • Does anyone know how to fix this? Everytime i make a new page it only types in the middle of the page. I want to type at the top
    11·1 answer
  • On tool hackers use to get sensitive information from victims is/are:
    15·2 answers
  • And this also please. help​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!