Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: NEED HELP! converting change given to money denominatons

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Thanked 0 Times in 0 Posts

    Default NEED HELP! converting change given to money denominatons

    Hi Guys!

    Well, my problem is i seem to not be able to convert the amountGiven back into change, such as dollars, quarters nickels, dimes, pennies. Heres my code: i hope its not to sloppy.. Ive just about ran out of ideas..

    import java.text.NumberFormat;

    public class Cashier {

    private static final double QUARTER_VALUE = 0.25;
    private static final double DIME_VALUE = 0.1;
    private static final double NICKEL_VALUE = 0.05;
    private static final double PENNY_VALUE = 0.01;
    private static final double DOLLAR_VALUE = 1.00;

    private static String name;
    private static double total;
    private double cost;
    private int numOfItems;
    private double aver;
    private double aver1;
    private double aver2;
    private double change;
    private double amountGiven;
    String s;

    private double penny,nickel,dime,quarter,dollar;

    NumberFormat nf = NumberFormat.getCurrencyInstance();

    public Cashier()
    name = "";
    s = "";
    total = 0.0;
    cost = 0.0;
    numOfItems = 0;

    public void add(String name, double cost)
    this.name = name;
    this.cost = cost;
    s = s + name + "....." + cost + "\n";
    numOfItems = numOfItems + 1;
    total = total + cost;

    public void average()
    aver = total / numOfItems;

    public void tendered(double Amount)
    amountGiven = Amount;

    public double getAG()
    return amountGiven;

    public void makeChange()
    change = amountGiven - total;

    public String getName()
    return s;

    public double getCost()
    return cost;

    public int getNumOfItems()
    return numOfItems;

    public double getTotal()
    return total;

    public double getAver()
    return aver;

    public double getChange()
    return change;

    public double Quarter()
    quarter =(int) change / 25;
    change = change % 25;

    return quarter;


    public double Dime(){

    dime = (change / 25)/10;

    return dime;

    public double Dollar(){

    dollar = (int)amountGiven / 100;
    amountGiven = amountGiven * 100;

    return dollar;


    public double nickel(){

    nickel = (change / 10)/5;

    return nickel;

    public double Penny(){

    penny = (change / 5)/1;

    return penny;


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 832 Times in 772 Posts
    Blog Entries

    Default Re: NEED HELP! converting change given to money denominatons

    This thread has been cross posted here:


    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

Similar Threads

  1. Make money today as a Java freelancer
    By JavaPF in forum Paid Java Projects
    Replies: 15
    Last Post: June 12th, 2014, 03:41 AM
  2. looking for java coders to code maplestory(big money)
    By sangozanji in forum Paid Java Projects
    Replies: 1
    Last Post: October 17th, 2011, 11:43 PM
  3. Converting Cases Help
    By Bradshjo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 27th, 2010, 12:07 PM
  4. [SOLVED] Help Converting to an Acronym
    By CheekySpoon in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 2nd, 2010, 01:37 PM
  5. Replies: 4
    Last Post: May 1st, 2009, 03:32 PM