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
1. image-editing software
Snezhnost [94]
  • PDF:-Portable Document Format
  • Database software:-software that organizes a collection of information
  • image-editing software :-software used to enhance photographs
  • presentation software :-software used to create a slide show
  • CAD:-software used to create technical drawings.

Done

8 0
2 years ago
Write a public static method diagSum, which takes a 2d array of int values as a parameter, and returns the sum of the elements i
saveliy_v [14]

A 2d array (i.e. 2 dimensional array) represents its elements in rows and columns

<h3>The program in Java</h3>

The method in Java, where comments are used to explain each line is as follows

//This defines the method

public static int diagSum(int[][] myArray) {

    //This initializes sum to 0

    int sum = 0;

    //This iterates through each row of the array

               for (int i = 0; i < myArray.length; i++) {

                   //This calculates the sum of the diagonals

                       sum+=myArray[i][i];

               }

               //This returns the sum

               return sum;

       }

Read more about methods at:

brainly.com/question/15969952

6 0
2 years ago
Novice drivers lack the experience necessary to reliably categorize and appropriately respond to ___________ hazards.
meriva

Answer:

roadside

Explanation:

Novice drivers lack the experience necessary to reliably categorize and appropriately respond to roadside hazards. A roadside hazard refers to any roadside objects or features that have a diameter greater than 100mm that is on or near the roadway. These are objects or features that are likely to create a dangerous environment to the drivers.

7 0
2 years ago
What are the main components of a desktop PC and briefly describe their purposes.​
Norma-Jean [14]

Answer:

8 Standard Computer Components and What They Do

Explanation:

Motherboard. The motherboard is an important computer component because it’s what everything else connects to!

Power Supply. True to its name, the power supply powers all other components of the machine.

Central Processing Unit (CPU)

Random-access Memory (RAM)

Hard Disk Drive / Solid State Drive.

Video Card.

Optical Drives.

6 0
2 years ago
What is the best game of 2020 in pc​
dybincka [34]

Answer:we have games like alien wars call of duty astro avengers

Explanation:8

8 0
3 years ago
Read 2 more answers
Other questions:
  • Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author'
    14·1 answer
  • Shelby likes to play video games on an old Atari video game system. No matter how old the cartridge, when she inserts it into th
    14·2 answers
  • There is an application which inputs hundred numbers from the user, if user enters a positive number it increments valid numbers
    6·1 answer
  • Missy loves her old Windows games. When she upgrades her Windows system, the games run fine, but the output looks fuzzy since th
    15·1 answer
  • Windows Rights Management Services is used in conjunction with which Microsoft applications?
    11·1 answer
  • A personal computer (pc) or ____ is a small computer system designed to be used by one person at a time.
    12·1 answer
  • Write a program to generate a square wave with 80% duty cycle on bit P2.7 Microprocessor.​
    7·1 answer
  • Devices which are used to receive data from central processing unit are classified as
    11·1 answer
  • Open the NetBeans IDE and create a new project named MySizes.java. Your program should do the following:
    9·1 answer
  • How many mb are in a gb?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!