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 is communication barriers?​
SSSSS [86.1K]

Answer:

A communication barrier is anything that prevents us from receiving and understanding the messages others use to convey their information, ideas and thoughts.They can interfere with or block the message you are trying to send.

7 0
3 years ago
Read 2 more answers
Why will my note 5 not download videos from the web?
meriva
Try downloading an app if the phone is not doing it.
7 0
3 years ago
What symbol is used for an assignment statement in a flowchart?
Annette [7]

Answer:

processing

Explanation:

The flow chart is a diagram that shows the activity of the program, peoples or things.

Flowchart symbol and meaning in the options:

1. Processing: it is a rectangular shape block which is used for variable declaration or assignment.

2. I/0: it is a parallelogram in shape which is used for input or output.

3. Parallelogram: it is used for input or output.

4. diamond: it is used for decisions or conditions.

Therefore, the correct option is a. Processing is the one that is used for the assignment statement.

3 0
3 years ago
Calcule la carga que puede levantar un cabrestante si la manivela mide 40 cm y el El radio del molinete es una tercera parte de
Luda [366]

Answer:

C

Explanation:

because...

5 0
2 years ago
Question 5) What is a feature of podcasts?
steposvetlana [31]

Answer:

the answer is a.they rely on airwaves for broadcasting

Explanation:

i just took this test on brainly

6 0
3 years ago
Read 2 more answers
Other questions:
  • A coworker asks your opinion about how to minimize ActiveX attacks while she browses the Internet using Internet Explorer. The c
    12·1 answer
  • A customer has a web server for a small business. The business uses both wired and wireless networking. A Linksys WRT300N wirele
    13·1 answer
  • Please help me complete this task for ICT! Its about Hardware and Software
    12·1 answer
  • Write a function called printEvens that prints all the even numbers between 2 and 20, inclusive. It will take no arguments and r
    6·1 answer
  • Provide the instruction type, assembly language instruction, and binary representation of instruction described by the following
    7·1 answer
  • Which browser should you choose if you want all viewing information except thumbnail previews of websites?
    15·2 answers
  • When Adobe Photoshop was released for the first time? A: 1984 B: 1990 C: 1991 D: 1992
    8·1 answer
  • Sam’s password is known to be formed of 3 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sa
    9·2 answers
  • What is connected to the base unit in Desktop PC?
    14·1 answer
  • Which browser feature will delete your history, cache, and cookies the moment you close the special window
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!