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
Find each of the following products using distributive property a) 735 × 16​
Alekssandra [29.7K]

Answer:

735 * 16 = 11760

Explanation:

Given

735 * 16

Required

The product using distributive property

Express 16 as 10 + 6

735 * 16 = 735 * (10 + 6)

Distributive property states that:

a * (b + c) = a * b + a * c

So, the expression becomes

735 * 16 = 735 * 10 + 735 *6

Evaluate each product

735 * 16 = 7350 + 4410

735 * 16 = 11760

8 0
3 years ago
. In testing, what is the role of an oracle?
ikadub [295]

Answer:

The role of test oracle is to determine if a test has passed or failed. Oracle compares the outputs of the system under a  test, for a given test-case input, and the output(s) that should have. A test oracle works on specifying constraints on the output(s) for a set of inputs. An oracle could be:

  • a program which tells if the output is correct.
  • documentation that specifies the correct output for inputs.
  • a human that can tell whether it is correct an output.

5 0
3 years ago
Write an application that allows a user to enter the names and birth dates of up to 10 friends. Continue to prompt the user for
mylen [45]
Sorry I don’t know the answer I am really sorry
5 0
3 years ago
I need an answer and fast What happens if a sequence is out of order?
horsena [70]

Answer:

i would say A

hope i helped <3

Explanation:

4 0
3 years ago
Read 2 more answers
What is known as networking in the IT field?
Sidana [21]

Answer:

r u Kate tell me plz I love u baby tell me please

4 0
2 years ago
Other questions:
  • Type the correct answer in the box. Spell all words correctly.
    9·1 answer
  • A slideshow that accompanies an oral report is known as what?
    6·1 answer
  • Que se puede observar en el escritorio de windows
    8·1 answer
  • Mention the generation we have in computer​
    7·1 answer
  • Cual es la fiabilidad de la innovacion tecnologica
    15·1 answer
  • Lesson 3 - Calling All Operators
    6·1 answer
  • Maya is preparing a presentation for her science class on how solar panels produce energy. Why would a
    11·2 answers
  • Tim has several workbooks open in the Excel application. He would like to view them all at the same time, so he should use the _
    14·1 answer
  • Which computer peripheral is used when you would like to use a DVD or CD?
    12·2 answers
  • State whether the given HTML coding is True or False. &lt;HR SIZE=5 COLOR=YELLOW ALIGN=RIGHT WIDTH=75%&gt;​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!