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
you have an ipv4 network that has two IPv6-only hosts that need to be able to communicate with each other. You want to implement
Soloha48 [4]

Answer:

Teredo tunnelling

Explanation:

The tunnelling method that will fit best in the situation is teredo tunnelling. The reason are embedded in its characteristics, they include;

Teredo tunneling has the following characteristics: Its tunnel endpoints are configured on hosts. The hosts are dual stack hosts and perform tunneling of ipv6 to send on the ipv4 network works through NAT the only solution that allows ipv4-only hosts to communicate with ipv6-only hosts is NAT-PT.

7 0
3 years ago
Does anybody play nitro type
vlabodo [156]

Answer: Nah

Explanation: it kinda sucks and is a waste of time, play better games lol

3 0
3 years ago
Read 2 more answers
What is the most important basic property of melody? Why?​
enot [183]

Most good melodies restrict their basic range to no more than an octave-and-a-half. Most good melodies use repeating elements. Listeners should be hearing certain melodic intervals, rhythms and other musical shapes repeating throughout the melody

5 0
3 years ago
Which of the following is not a network category based on the geographic dispersion of network components?
barxatty [35]

Answer:B) Wide-Area Network (WAN)

Explanation: WAN(Wide area network)is the network which constitutes a large geographical region.This network consist of the small network unit as well as large network connections.This network does not have the geographic dispersion of the components of networks.

WAN works in geographic region for the dispersion between any two locations. Other options are incorrect because they connect the network components geographically. Thus the correct option is option(B).

7 0
4 years ago
What type of operating system is Linux? An outsourced operating system An open source operating system A closed source operating
Lesechka [4]

Answer:

An open source operating system

Explanation:

Linux is an open source operating system (OS). An operating system is the software that directly manages a system's hardware and resources, like CPU, memory, and storage.

8 0
3 years ago
Other questions:
  • Bob's Assembly is a hardware manufacturer. It specializes in builders' hardware for doors, cabinets, windows, and bathrooms. Bob
    10·1 answer
  • Why are listening and speaking part of the Common Core and ELD Standards? Why is this particularly important for our ELD student
    14·1 answer
  • Karen thinks she should go out with Blane, an unattractive, social misfit, because “If I don’t go out with him, people will thin
    7·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • In a proper webpage, which tag holds all of a webpages visible HTML?
    5·1 answer
  • The ArrayList class ____ method returns the current ArrayList size.
    8·1 answer
  • An ink-jet printer is a type of impact printer. <br> a. True <br> b. False
    8·1 answer
  • An abstract method ____.
    6·1 answer
  • List three social implications of the wider range of piracy​
    15·1 answer
  • Question 1 (10 points)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!