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
Stephen needs to insert a field into a building block that will contain variable data. Which keyboard shortcut can he use to tog
STatiana [176]

Answer:

Alt + F9

Explanation:

The Keyboard shortcut that Stephen can use use to toggle between data and the field codes is Alt + F9. This is in regards to Microsoft Word Fields for both Windows and Mac operating systems. Although ALT + F9 will toggle between these two but for all the fields within the document. If you want to toggle between a single or various fields it would be Shift + F9.

8 0
2 years ago
What is the purpose of netiquette guidelines?
sp2606 [1]
The purpose of netiquette guidlelines is to provide a safe and secure environment for internet users everywhere
7 0
3 years ago
9. Question
Gennadij [26K]
A server stopped provide service to 100 users
5 0
2 years ago
The variables xp and yp have both been declared as pointers to integers , and have been assigned values (i.e., they are each poi
Amanda [17]

Answer:

Following code are:

int *temp;   //declaration of variable

// perform swapping

temp = xp;    

xp = yp;

yp = temp;

Explanation:

we declare an integer data type pointer variable "*temp"  then perform swapping between them.

The variables "xp" and "yp" are already declared and these variables are performing swapping among three.

6 0
3 years ago
Which of the following is a set of short-range wireless technologies used to share information among devices within about two in
8_murik_8 [283]

Answer:

Option (c) NFC

Explanation:

  • The NFC Technology is a Wireless Technology which works in the range of 10 cm or less.
  • NFC stands for Near Field Communications.
  • The name itself indicates that it a communication mode with the near by objects.
  • The NFC technology is used in Access Cards, Payment Cards and Mobile Devices etc.
  • Option (a) IM - Instant Messaging is the instant text messaging technology sends and receives messages over the internet. It is used in Social Media where instant messaging is available. So, option (a) is not correct option.
  • Option (b) text messaging the technology is the technology in which the text messages are sent over the mobile networks ( in case of text messaging in mobile phones ) or over the internet ( emails, blogging etc). So, option (b) is not correct option.
  • Option (d) DES is not a short range wireless technology. So, option (d) is not correct.
  • Option (c) NFC is correct option.
3 0
2 years ago
Other questions:
  • Point mode allows you to select cells for use in a formula by using your finger or the pointer
    7·1 answer
  • Peripherals can be used to input information. True False
    6·2 answers
  • What were precomputed tables and why were they necessary?​
    12·2 answers
  • What is the main reason that IT managers believe the future IT career model will be diamond-shaped, with few entry-level IT jobs
    7·1 answer
  • Write a C++ program to find if a given array of integers is sorted in a descending order. The program should print "SORTED" if t
    14·1 answer
  • The purpose of​ a/an _________ system is to capture best practice solutions and program them into a set of rules in a software p
    13·1 answer
  • A cpu handless all the instruction that it recieces from hard ware and software which are available on the computer true or fals
    7·1 answer
  • For java
    7·1 answer
  • Which of the following keywords is used to remove a row in a table? (Points : 2) DROP
    11·1 answer
  • Plz hurry it’s timed
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!