Question

Need help working with Eclipse for Java. I must write an application that reads a monetary...

Need help working with Eclipse for Java. I must write an application that reads a monetary amount, and then determines the fewest number of each bill and coin needed to represent that amount, starting with the highest (assuming $10 bill is the maximum size needed).

Enter monetary amount: 47.63 That's equivalent to (order must follow from high to low): 4 ten dollar bills 1 five dollar bills 2 one dollar bills 2 quarters 1 dimes 0 nickels 3 pennies.

All the code I have right now is:

package moneyconvert;

public class CSProj1 {

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CSProjl.java

import java.util.Scanner;

public class CSProj1 {
    public static void main(String args[]){
        float amount;
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter amount: ");
        amount = scanner.nextFloat();
        if(amount > 10){
            System.out.println("$10-"+(int)(amount/10));
            amount = amount % 10;
        }
        else {
            System.out.println("$10-0");
        }
        if(amount > 5){
            System.out.println("$5-"+(int)(amount/5));
            amount = amount % 5;
        }
        else {
            System.out.println("$5-0");
        }
        if(amount > 1){
            System.out.println("$1-"+(int)(amount/1));
            amount = amount % 1;
        }
        else {
            System.out.println("$1-0");
        }
        if(amount > 0.25){
            System.out.println("Quarters-"+(int)(amount/0.25));
            amount = (float) (amount - ((int)(amount/0.25) * 0.25));
        }
        else {
            System.out.println("Quarters-0");
        }
        if(amount > 0.10){
            System.out.println("Dimes-"+(int)(amount/0.10));
            amount = (float) (amount % 0.10);
        }
        else {
            System.out.println("Dimes-0");
        }
        if(amount > 0.05){
            System.out.println("Nickles-"+(int)(amount/0.05));
            amount = (float) (amount % 0.05);
        }
        else {
            System.out.println("Nickles-0");
        }
        if(amount > 0.01){
            System.out.println("Pennies-"+(1 +(int)(amount/0.01)));
            amount = (float) (amount % 0.01);
        }
        else {
            System.out.println("Pennies-0");
        }
    }
}

\color{red}\underline{Output:}

47.63 $10-4 $5-1 $1-2 uarters-2 Dimes-1 Nickles-0 Pennies-4 Process finished with exit code 0

Add a comment
Know the answer?
Add Answer to:
Need help working with Eclipse for Java. I must write an application that reads a monetary...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) 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 Quarter 2 Dimes So...

  • Write a class encapsulation the concept of coins (Coins java), assuming that coins have the following...

    Write a class encapsulation the concept of coins (Coins java), assuming that coins have the following attributes: a number of quarters, a number of dims, a number of nickels, and a number of pennies. Include a constructor (accept 4 numbers that represent the number of coins for each coin type), mutator and accessot methods, and method tostring. The tostring method should return a string in the following format: Total Value: $5.50 10 quarters, 20 dimes, 19 nickels, and 5 pennies...

  • 2. Write a JAVA program that prints the numbe r of quarters, dimes, nickels, and pennies...

    2. Write a JAVA program that prints the numbe r of quarters, dimes, nickels, and pennies that a customer should get back as change. Declare and initialize all memory locations as integers. On Output show the original change amount as a monetary amount with the two positions of decimal. Run your program once by performing a compile-time initializations using 92 cents for the calue to be converted. Go into your source code and change the 92 to 27. Return the...

  • How do I type 2.18 into java? We have to make up a scenario and put...

    How do I type 2.18 into java? We have to make up a scenario and put it into netbeans java. range increases byte, short, int, long, float, double Lab2: Calculate Changes Problem Statement: This program lets the user enter the amount in decimal representing dollars and cents and output a report listing the monetary equivalent in single dollars, quarters, dimes, nickels, and pennies. Your program should report maximum number of dollars, then the maximum number of quarters, and so on,...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • Step One This is the Measurable interface we saw in class; you will need to provide...

    Step One This is the Measurable interface we saw in class; you will need to provide this class; this is it in its entirety (this is literally all you have to do for this step): public interface Measurable double getMeasure(); Step Two This is the Comparable interface that is a part of the standard Java library: public interface Comparable int compareTo (Object otherObject); Finish this class to represent a PiggyBank. A PiggyBank holds quarters, dimes, nickels, and pennies. You will...

  • Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number...

    Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two constructors (non-argument constructor that assigns 1 to each coin, and another constructor that takes necessary arguments to create an object), needed getter and setter methods, method toString (to print coins objects in a meaningful way), and method equals (to compare two coins objects based on number of coins). Also include...

  • Due: Wednesday June 10, 2020 A travel company has many British travelers going to the US...

    Due: Wednesday June 10, 2020 A travel company has many British travelers going to the US who would like to exchange their British Pounds into American dollars. They want you to explain how the American dollar amount will translate to the number of different bills and coins. There are many different ways to split a particular dollar amount into bills and coins, but they want to have as many high denomination bills and coins as possible. Assume that the highest...

  • I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at...

    I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at all, it is just left blank. package edu.wit.cs.comp1050; /** * Solution to the third programming assignment * When it runs it outputs the amount in quarters, dimes, nickels and pennies * * @author Rose Levine * */ import java.util.Scanner; public class PA1c {       /**    * Error message to display for negative amount    */    public static final String ERR_MSG =...

  • Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10...

    Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. 2. Repeatedly prompt the user for a price in the form xX.xx, where X denotes a digit, or to enter q' to quit 3. When a price is entered a. If the price entered is negative, print an error message and start over requesting either a new price or to quit (indicated by entering a 'q)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT