Question

Create a Change application that prompts the user for an amount less than $1.00 and then...

Create a Change application that prompts the user for an amount less than $1.00 and then displays the minimum number of coins necessary to make the change. The change can be made up of quarters, dimes, nickels, and pennies. The application output should look similar to:

Enter the change in cents: 212

The minimum number of coins is:

Quarters: 8

Dimes: 1

Nickels 0

Pennies: 2

Must be coded in Java please

Homework Answers

Answer #1
//CoinExchange.java
import java.util.Scanner;
public class CoinExchange {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter the change in cents: ");
        int n = scan.nextInt();

        System.out.println("Quarters: "+(n/25));
        n = n%25;

        System.out.println("Dimes: "+(n/10));
        n = n%10;

        System.out.println("Nickels: "+(n/5));
        n = n%5;

        System.out.println("Pennies: "+(n));
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a Grade application that prompts the user for the percentage earned on a test or...
Create a Grade application that prompts the user for the percentage earned on a test or other graded work and then displays the corresponding letter grade. The application should use the grading scale at your school or the following grading scale: 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D below 60 F The application output should look similar to: Enter your marks: 90 Grade: A Notes: coded in java. Please don't make...
Create a DigitsSum application that prompts the user for a non-negative integer and then displays the...
Create a DigitsSum application that prompts the user for a non-negative integer and then displays the sum of the digits. ( Java Programming )
USE PYTHON Please!!! 4.15 LAB: Exact change Write a program with total change amount as an...
USE PYTHON Please!!! 4.15 LAB: Exact change Write a program with total change amount as an integer input, and output the change using the fewest coins, one 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 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive the amount and declare the variable double amount for scanner Declare variable integer remaining amount which is equal to (int) (amount*100) Find the number of one dollars bt declaring the integer variable which is equal to remaining amount divided by 100 Declare: remaining amount %=100 Find the number of quarters: Declare integer variable number of quarters equal to remaining amount divided by 25 Declare:...
Write a program that input some number of cents (see less than 100), and output the...
Write a program that input some number of cents (see less than 100), and output the number of quarters, dimes, nickels and pennies needed to add up to that amount (thinking how a cashier needs to return you back some small changes).
program has to be written in X86 processor assy language. Write a program that find the...
program has to be written in X86 processor assy language. Write a program that find the minimum number of coins that can represent an amount of money under $1. The amount of money is a random number between 0 and 99 (cents). The randomRange procedure is used to get a random number. Review the sample code in lab4.asm and run it to see how randomRange works. Each time randomRange is called, it creates a random number between 0 and the...
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the...
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the number of interior and exterior murals scheduled to be painted during the next month. The program computes the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. In this assignment, you are going to design a GUI version using Visual Studio Form. The programs prompt a user for the number of interior and exterior...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
Design a FSM for a Vending Machine In this task, you will design a FSM for...
Design a FSM for a Vending Machine In this task, you will design a FSM for a simple (albeit strange) vending machine of office supplies. The vending machine sells three possible items, each at a different cost: Item Cost Pencil 10 cents Eraser 20 cents Pen 30 cents The vending machines accepts nickels (worth 5 cents), dimes (worth 10 cents), and quarters (worth 25 cents). Physically, it is only possible to insert a single coin at a time. The vending...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...