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 are parts of the prewriting process
Rainbow [258]
The prewriting process should include brainstorming a topic, deciding on which topic on which to write, research of a topic, organizing the research into a comprehensive whole. Check out an APA style textbook, should be available at the library, and it should have more results in the prewriting process. Of course, the writing process itself depends on the individual and his or her cognitive process on writing.

6 0
3 years ago
Read 2 more answers
What field in a TCP segment is used to determine if an arriving data unit exactly matches the data unit sent by the source?
Rina8888 [55]

Answer:

a. Checksum

Explanation:

Based on the information provided within the question it can be said that the field that represents this information is called the Checksum. Like mentioned in the question this refers to a value that represents the amount of bits in a certain transmission message. This is done in order to make sure that the amount of bits that were sent match the amount that were received in order to make sure that no data was lost in transit that would cause high-level errors.

7 0
3 years ago
This term is also called live, or hot, which means that a voltage is present and it can cause an electrical current. Any time an
tangare [24]
B. Energised although this is not as common
3 0
3 years ago
Pre-Test
ozzi

Some of the options in this question are not correct; here is the correct and complete question:

In order for a fictionalized story to be based on real events, the author should include

A. Characters with strong feelings

B. Historical material

C. A narrator

D. Dialogue​

The correct answer is B. Historical material

Explanation:

Stories, novels, and poems are said to be based on real events if these include or are inspired by real people, settings, or historical events. This includes using any historical material and adapting it to create a story. For example, the play "The Tragedy of Julius Caesar" written by Shakespeare is a play based on real events as it includes real characters such as Julius Caesar and some of the events in it are based on historical events.

According to this, the element that is necessary to make a story to be based on real events is historical material. Also, others such as a narrator, dialogue, or characters with strong feelings can be found in most stories including those that are completely fictionalized.

3 0
3 years ago
What value(s) can be input into this code for the value of number that will cause the code in the loop to execute? Scanner keybo
Marianna [84]

Answer:

There is no value of the number variable, for which the loop can be true in any iteration.

Explanation:

  • The above loop states the condition that the value should be less than 100 and greater than 500. It is because the loop holds the and condition which gives the true if both conditions will be true.
  • The first condition of the while loop states that the value of the number variable is less than the 100.
  • The second condition of the while loop state that the value of the number variable is greater than the 500.
  • The and condition of the while loop will true if both conditions will true.
  • But there is no number which is less than 100 and greater than 500.
  • So no number can satisfy the while condition to be true.

5 0
3 years ago
Other questions:
  • Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the us
    15·1 answer
  • A raised dot (ú) shows where the enter key was pressed. true or false.
    13·1 answer
  • (Game Design) Which of the following is NOT a name of a popular digital sculpting application?
    13·1 answer
  • Which of the following image file formats uses lossy file compression?
    7·1 answer
  • Encryption Using Rotate Operations Write a procedure that performs simple encryption by rotating each plaintext byte a varying n
    10·1 answer
  • Read the four detective reports and the combined affidavit and warrant for the M57 Patents case. Write a one- to two-page paper
    5·1 answer
  • 3.2 lesson practice edhesive ​
    6·1 answer
  • The set of rules for how computers talk to one another
    6·1 answer
  • The computer system for a major retail store was hacked. Many addresses, credit card numbers, and other pieces of customers’ per
    7·2 answers
  • How to edit slides into video.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!