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
Write a statement that reads 5 successive integers into these variables that have already been declared: x1, x2, x3, x4, x5. The
prisoha [69]

Answer:

Following are the statement in C++ language :

#include <iomanip> // header file  

using namespace std; // namespace

int main() // main method  

{

   int x1,x2,x3,x4,x5; // variable declaration

cout<<" Enter the 5 sucessive integer:";

cin>>x1>>x2>>x3>>x4>> x5; // taking 5 input from user

cout<<right;

// prints each  of  its own line and form a right-justified  

cout<<setw(5)<< x1 << "\n" << setw(5) << x2 << "\n" <<setw(5) << x3 << "\n" << setw(5) << x4 << "\n" << setw(5) << x5 << "\n";

return(0);    

}

Output:

Enter the 5 sucessive integer: 45

23

445

6

8

 

  45

  23

 445

   6

   8

Explanation:

Description of program is given below  

  • Declared a 5 integer value x1,x2,x3,x4,x5 respectively.
  • Read the 5 integer value from user by using cin funtion.
  • Finally Print these 5 value in its own line and form a right-justified by using setw() function on it
5 0
3 years ago
There's a right and a wrong way to act on the internet. The right way includes practicing proper netiquette.
DaniilM [7]

Answer:

Netiquette is a combination of the words network and etiquette and is defined as a set of rules for acceptable online behavior. Similarly, online ethics focuses on the acceptable use of online resources in an online social environment.

  • Be Careful With Your Tone.
  • Be Accurate and Factual.
  • Search First, Then Ask.
  • Don't Use Sarcasm Freely.
  • Be as Polite as You Are In Person.
7 0
2 years ago
Read 2 more answers
Please answer questions in complete sentences!
Troyanec [42]

i need help on that too :cc

7 0
2 years ago
you would like to enter a formula that subtracts the data in cell b4 from the total of cells b2 and b3. what should the formula
pashok25 [27]
I believe the answer would be B taking b2 and b3 together and then subtracting b4 from the total number
4 0
3 years ago
Read 2 more answers
1. Write Python code to implement the following:
ZanzabumX [31]

Answer: no why huh hmmmmmmm

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • Which principle of design is she following
    9·1 answer
  • To order the records in the answer to a query in a particular way, you ____ the records.
    11·1 answer
  • What type of document would you use the landscape page orientation
    7·1 answer
  • What inventor patented the first American movie projector?
    14·2 answers
  • Write a program that unpickle's employee dictionary and while reading from the dictionary, it allows users to lookup an employee
    9·1 answer
  • Before using large downloaded files that are in a compressed format, it is necessary to_____ them. A) Copy B) Extract C) Open D)
    9·1 answer
  • Explain how computer system is different from computer in 150 words
    14·1 answer
  • fill in the balenkes ) 1)there are ................................... function keys on the keybord 2)pressing the end key moves
    6·1 answer
  • In this lab, your task is to complete the following: Enable all of the necessary ports on each networking device that will allow
    9·1 answer
  • Question No. 5:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!