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
What phone had emojis first?
irina1246 [14]
I believe it was IPhone
3 0
3 years ago
Read 2 more answers
To insert a footnote in a document, a user would navigate to the _____ tab.
Pachacha [2.7K]

Answer

References tab.

Explanation

In MS word documents, you can add footnotes and endnotes by;

• Clicking the area to add a footnote

• Clicking references, then insert Footnote. The word program will insert a reference mark in the text and will add the footnote mark at the bottom of the page

• Type a footnote text.

Hope this Helps!

3 0
3 years ago
Read 2 more answers
What is a multipurpose network device?
exis [7]

Answer:

A switch connects multiple devices to a network. ... devices are usually integrated into a multipurpose network device

7 0
3 years ago
If any one answered this i will give brilientst what is stimulation program​
7nadin3 [17]

Explanation:

organized programs of enrichment designed to provide developmentally appropriate activities to babies and toddlers who have, or who are at risk for a variety of conditions (environmentally or biologically caused) that might interfere with their ability to ultimately have a full and productive life."

4 0
3 years ago
Using the phase plane program described in the introduction, plot the phase plane for the Lotka-Volterra model Here represents t
dezoksy [38]

Answer:

Check the explanation

Explanation:

Kindly check the attached image.

The attached image below describes the inner equilibrium point is a stable node, here it's a center. These are periodic solutions. Populations of the mice and owls are periodic. It describes: when the mice population is lower, the owl population decreases; again the owl is lower so mice got a chance to grow its population; now as sufficient food(mice) is there, the owl population increases; as predator population increases, the prey population decreases;  and this continues as a cycle forever.

So, yes, the model gives a realistic behavior.

4 0
4 years ago
Other questions:
  • You friends parents are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    10·1 answer
  • Write a recursive function that takes a non-negative integer as an argument and displays the same number in reverse order (i.e.
    15·1 answer
  • Do you think robots will take millions of jobs when they're put in different positions such as doctors or taxi drivers?
    7·1 answer
  • Which type of software has no restrictions from the copyright holder regarding modifications of the software’s internal instruct
    10·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • Which best describes the benefits of renting a home
    12·2 answers
  • Advantage of realtime processing​
    14·1 answer
  • Which U.S. government agency first funded the development of the Internet?
    12·2 answers
  • A force from water that brings water to your house​
    6·1 answer
  • How to assign some object key values to other name react const.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!