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
Gwar [14]
3 years ago
13

in java Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, o

ne coin type per line. 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: 0 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes
Computers and Technology
1 answer:
Keith_Richards [23]3 years ago
3 0

Answer:

// Program is written in Java

// Comments are used for explanatory purposes

// Program starts here..

import java.util.*;

public class Money

{

public static void main(String [] args)

{

 Scanner input = new Scanner(System.in);

 // Declare Variables

 int amount, dollar, quarter, dime, nickel, penny;

 // Prompt user for input

 System.out.print("Amount: ");

 amount = input.nextInt();

 // Check if input is less than 1

 if(amount<=0)

  {

   System.out.print("No Change");

  }

 else

  {

   // Convert amount to various coins

   dollar = amount/100;

   amount = amount%100;

   quarter = amount/25;

   amount = amount%25;

   dime = amount/10;

   amount = amount%10;

   nickel = amount/5;

   penny = amount%5;

   // Print results

   if(dollar>=1)

    {

     if(dollar == 1) { System.out.print(dollar+" dollar\n");}

   else { System.out.print(dollar+" dollars\n"); }

}

if(quarter>=1)

{

if(quarter== 1)

{System.out.print(quarter+" quarter\n");}

else{System.out.print(quarter+" quarters\n");}

}

if(dime>=1)

{

if(dime == 1){System.out.print(dime+" dime\n");}

else{System.out.print(dime+" dimes\n");}

}

if(nickel>=1)

{

if(nickel == 1){System.out.print(nickel+" nickel\n");}

else{System.out.print(nickel+" nickels\n");}

}

if(penny>=1)

{

if(penny == 1) {System.out.print(penny+" penny\n");}

else { System.out.print(penny+" pennies\n"); }

}

}

}

}

See attachment for program file

Download java
You might be interested in
Please what do you guys think about this ?
Y_Kistochka [10]

Answer:itsjust black

Explanation:

Black thoughts

3 0
3 years ago
Read 2 more answers
Which of the following Office Online apps is most effective for creating multi-media presentations
lubasha [3.4K]
PowerPoint would be best for multi-media presentations. It allows you to include pictures and videos to make your presentation more effective. You can also select the appropriate themes, color schemes, animations, and transitions to make it more appealing as well.
4 0
3 years ago
How does a router differ from such devices as repeaters, bridges, and switches?
irina1246 [14]

Answer: Please see below as the answer is self-explanatory

Explanation:

Repeaters, bridges and switches, route packets only within the limits of  their own physical networks, using the physical hardware addresses of the different devices connected to the network.

On the contrary, routers are devices that interconnect physical networks, with one physical interface per each network to which the router is connected to.

Routers use logical addresses -called IP addresses in the TCP/IP suite, which operate at the network level, and take charge of the delivery of packets beyond the network that originated it, based on the IP address of the destination host.

Only when the IP destination address is within the same physical network as the router, it transforms the IP datagram in a Frame and sends it using the physical hardware address of the host.

8 0
3 years ago
When tcp/ip was developed, the host table concept was expanded into a hierarchical name system for matching computer names and n
zmey [24]
DNS, Domain Name Service, (a.o.) it translates computer names into ip addresses
4 0
3 years ago
Which of the following best explains how algorithms that run on a computer can be used to solve problems?
timama [110]

The statement which best explains how algorithms running on a computer can be used to solve problems is; D. Some problems cannot be solved by an algorithm.

<h3>What is an algorithm?</h3>

An algorithm is simply a standard formula or procedures which is made up of a set of finite steps and instructions that must be executed on a computer, so as to proffer solutions to a problem or solve a problem under appropriate conditions.

However, it should be noted that it is not all problems that can be solved by an algorithm, especially because the required parameters and appropriate conditions are not feasible or met.

Read more on algorithm here: brainly.com/question/24793921

7 0
2 years ago
Other questions:
  • How many megabytes of data can a factory made audio cd hold?
    13·1 answer
  • I NEED HELP NOW PLEASE!!!!!!
    6·2 answers
  • Is anyone really good at immerse 2 learn??
    9·1 answer
  • Which two actions allow the System Administrator to limit Chatter access during roll-out to a subset of Salesforce users?
    9·1 answer
  • Select the correct answer.
    15·1 answer
  • When you purchase donuts, they come in boxes of 12, so 24 donuts take 2 boxes. All donuts need to be in a box, so if you buy 13
    10·1 answer
  • Multiple Choice
    8·1 answer
  • What is the output?
    11·1 answer
  • Davingould1115...................answer 2​
    11·2 answers
  • 100 POINTS!!!!!!!
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!