Help with printing out the # of quarters, nickels, dimes, and etc... using

Hi, im new to java and im using a program called blue j.
anyway heres my question.
, I recommend you dont do the program for me, but rather help gear me in the right direction of things.
In this program they want me to have it print out the # of dollars,quarters,nickels,dimes, and pennies.
They have provided me with a base program to start off with which is this.
import chn.util.*;
public class ComputeChange
   *  The main program for the Change class
   * @param  args  The command line arguments - not used
  public static void main(String[] args)
    double purchase, cashPaid, temp;
    int change, remainder, dollars, quarters, dimes, nickels, pennies;
    ConsoleIO keyboard = new ConsoleIO();
    System.out.print("Enter amount of purchase --> ");
    purchase = keyboard.readDouble();
    System.out.print("Enter amount of cash paid --> ");
    cashPaid = keyboard.readDouble();
    temp = cashPaid - purchase;
    dollars = (int) temp;
    temp = temp - (int)temp + 0.0000001;
    change = (int)(temp * 100);
    System.out.println();
    System.out.println("$" + dollars + "." + change);
}Ive been given the amounts 23.06 for amount of purchase
and 30.00 for the amount paid. that should give me the difference of $6.94
It should print out the amount of change as the following
6 dollars
3 quarters
1 dime
1 nickel
1 penny.
IVe tried a few methods for printing out the # of each coin type, but i simply dont get how they are using temp or what type of funciton i need to follow. Any hints or pointings in the right direction would help. Since i need to learn this.
Thanks a lot and i hope i can get some tips. !
~Jbinks

And here's my contribution to the scratch batch... :o)
class Coins {
    private java.util.Map<Coin, Integer> count = new java.util.HashMap<Coin, Integer>();
    enum Coin {
        DOLLAR(100), QUARTER(25), DIME(10), NICKEL(5), PENNY(1);
        private final int value;   
        Coin(int value) { this.value = value; }
        public int value() { return value; }
    public Coins(int centsValue) {
        for (Coin c : Coin.values()) {
            count.put(c, centsValue / c.value());
            centsValue %= c.value();
    public void display() {
        for (Coin c : Coin.values()) {
            System.out.println(c + ": " + count.get(c));
public class CoinsDemo {
    private static java.util.Scanner keyboard = new java.util.Scanner(System.in);
    public static void main(String[] args) {
        int price = getPennies("Enter amount of purchase --> ");
        int paid = getPennies("Enter amount of cash paid --> ");
        new Coins(price - paid).display();
    private static int getPennies(String prompt) {
        System.out.print(prompt);
        double d = keyboard.nextDouble();
        System.out.println();
        return (int)(d * 100);
}

Similar Messages

  • Help with printing out Speakable Items folder(s)

    I have a visually impaired family member who would like to learn how to use spoken commands on her iMac. 
    I have not been able to find a way to print out the "Speakable Items" folder(s) in order for us to let her know what exactly she can say; it is not at all feasible for her to read it from the screen.
    It's very, very frustrating for everyone to have the Speakable Items feature available, and not be able to use it properly!

    Thanks Niel! 
    Having it printed out in the way you suggested helped me.  To make the text large enough for the person with visual impairment to "see", I also resorted to actually typing them out in Pages and making it about 72pt;  I had to print it out so that they can hold the paper right up to their face. 

  • Help with print out of object

    I have a tutorial class that sets two Rational objects....generates a fraction for them and prints them out., but its only printing out the same object twice.
    Why is it not printing out the instance variables for both objects and how do I fix this?
    Tutorial class
    import java.util.Random;
    import java.util.Scanner;
    public class Tutorial {
      public static void main(String[] args) {
        Random randNumGen = new Random();
        Scanner scan = new Scanner(System.in);
        //Generate random fractions
        Rational fraction1, fraction2;
        fraction1 = new Rational(randNumGen.nextInt(101), randNumGen.nextInt(101));
        fraction2 = new Rational(randNumGen.nextInt(101), randNumGen.nextInt(101));
        //Prompt user for the sum of the 2 fractions
        System.out.print("Enter the sum of " + fraction1 + " + " + fraction2 +
            " = ");
        Rational guessFractionSum = Rational.readRational(scan);
        //Start the tutorial
        StartTutorial.displayASession(fraction1,fraction2,guessFractionSum);
        //Generate random rectangles
    //    RectangleOperand rect1, rect2;
    //    rect1 = new RectangleOperand(randNumGen.nextInt(101),randNumGen.nextInt(101));
    //   rect2 = new RectangleOperand(randNumGen.nextInt(101),randNumGen.nextInt(101));
        //Prompt the user for the sum of the rectangles
    //   System.out.print("Enter the sum of " + rect1 + " + " + rect2 +
      //                   " = [x=0.0,y=0.0,w=");
    //   RectangleOperand guessRect = RectangleOperand.readRectangle(scan);
        //Start the tutorial
    //    StartTutorial.displayASession(rect1,rect2,guessRect);
    }Rational Class
    import java.util.*;
    public class Rational implements Addable<Rational> {
      private static int numerator, denominator, gcdNum, count = 0;
       * Default constructor
      public Rational() {
       * Accepts the numerator and denominator
       * @param n int
       * @param d int
      public Rational(int n, int d) {
        numerator = n;
        denominator = d;
        if (denominator == 0)
          denominator = 1;
        gcdNum = gcd(numerator, denominator);
        numerator = numerator / gcdNum;
        denominator = denominator / gcdNum;
       * Adds the two random generated fractions
       * @param opnd2 Rational
       * @return Rational
      public Rational plus(Rational opnd2) { //from Addable interface
        int numerator1, denominator1, gcd, n, d;
        numerator1 = (this.numerator * opnd2.denominator) +
            (this.denominator * opnd2.numerator);
        denominator1 = this.denominator * opnd2.denominator;
        gcd = gcd(numerator1, denominator);
        n = numerator1 / gcd;
        d = denominator1 / gcd;
        Rational rationalPlus = new Rational(n, d);
        return rationalPlus;
       * Checks the sum of two random fractions with the user guess
       * @param opnd2 Rational
       * @return boolean
      public boolean equalTo(Rational opnd2) { //from Addable interface
        boolean isEqual;
        if (this.numerator == opnd2.numerator &&
            this.denominator == opnd2.denominator) {
          isEqual = true;
        else
          isEqual = false;
        return isEqual;
       * Reads in the guess from the user
       * @param scan Scanner
       * @return Rational
      public static Rational readRational(Scanner scan) {
        int fraction;
        fraction = scan.nextInt();
        String fractionS = String.valueOf(fraction);
        String[] fractionA = fractionS.split("/");
        numerator = Integer.parseInt(fractionA[0]);
        denominator = Integer.parseInt(fractionA[1]);
        Rational rationalScan;
        return rationalScan = new Rational(numerator, denominator);
       * Finds the greatest common factor from the random fractions
       * @param num1 int
       * @param num2 int
       * @return int
      private int gcd(int num1, int num2) {
        while (num1 != num2)
          if (num1 > num2)
            num1 = num1 - num2;
          else
            num2 = num2 - num1;
        return num1;
       * toString
       * @return String
      public String toString() {
        String text;
        text = numerator + "/" + denominator;
        return text;
    }

    numerator and denominator are static, meaning there's only one instance of it that's shared across all objects of that type. So each Rational you create is sharing the same variable.

  • Help with printing out colored text.

    Basically i just have a String, that i want to print to the screen,
    using System.out.println();
    But i want to give it a RGB value.
    Can anyone tell me the simplest way to do this?

    Can't do that in Java. You can use ANSI codes to control the presentation of the cmd window.
    Search the web for "ANSI control codes"

  • Is it possible to get out the rotation angle between template and shape using shape matching.vi?

    I want to determine the orientation of a particle shape.
    Using pattern matching is influenced by the texture of the particle.
    Shape matching would be the right but I don't see a possibility to get the rotation angle of the found shape and template respectively.
    Any idea?

    You could try using particle analysis to give you the particle orientation. There is an example of this that ships with the Vision toolkit. Go to the Vision examples and look under Funtions>Binary Analysis and it is called Particle Orientation Example.
    Cheers,
    JRA
    Application Engineer
    National Instruments

  • Why can't I print out the body of my emails,they come out with the right missing.

    When ever I try to print out my emails(gmail) everything under the Mail column prints,but the right side is missing. I have tried everything I know and nothing works. I can't move it over and I can use the print selection. Also I can't print out the entire email if it is more than 1 page.

    First try to reset Firefox printer settings, if you are still unable to print you can then reset '''all '''firefox printer settings.
    ''Reset firefox printer settings:''
    1. In the Location bar, type about:config and press Enter.
    2. In the Filter field, type print.print_printer.
    3. Right-click on the print.print_printer setting and select Reset.
    4. At the top of the Firefox window, click on the Firefox button (File menu in Windows XP) and then click Exit.
    ''The first way was just simple reset of firefox printer settings. However, if it failed to solve the problem then you need a full reset of all firefox printer settings. ''
    1. Open your profile folder: At the top of the Firefox window, click on the Firefox button, go over to the Help menu (on Windows XP, click on the Help menu) and select Troubleshooting Information. The Troubleshooting Information tab will open.
    2. Under the Application Basics section, click on Open Containing Folder. A window with your profile files will open. Note: If you are unable to open or use Fire​fox, follow the instructions in Finding your profile without opening Firefox.
    3. At the top of the Firefox window, click on the Firefox button (File menu in Windows XP) and then click Exit.
    4. In your profile folder, copy the prefs.js file to another folder to make a backup of it.
    5. Open the original prefs.js file in a text editor (such as Wordpad).
    6. Remove all lines in prefs.js that start with print. and save the file.
    See:
    [[Firefox prints incorrectly]]

  • How do I  print out the attributes of objects from a  Vector?  Help !

    Dear Java People,
    I have created a video store with a video class.I created a vector to hold the videos and put 3 objects in the vector.
    How do I print out the attributes of each object in the vector ?
    Below is the driver and Video class
    Thank you in advance
    Norman
    import java.util.*;
    public class TryVideo
    public static void main(String[] args)
    Vector videoVector = new Vector();
    Video storeVideo1 = new Video(1,"Soap Opera", 20);
    Video storeVideo2 = new Video(2,"Action Packed Movie",25);
    Video storeVideo3 = new Video(3,"Good Drama", 10);
    videoVector.add(storeVideo1);
    videoVector.add(storeVideo2);
    videoVector.add(storeVideo3);
    Iterator i = videoVector.interator();
    while(i.hasNext())
    System.out.println(getVideoName() + getVideoID() + getVideoQuantity());
    import java.util.*;
    public class Video
    public final static int RENT_PRICE = 3;
    public final static int PURCHASE_PRICE = 20;
    private int videoID;
    private String videoName;
    private int videoQuantity;
    public Video(int videoID, String videoName, int videoQuantity)
    this.videoID = videoID;
    this.videoName = videoName;
    this.videoQuantity = videoQuantity;
    public int getVideoID()
    return videoID;
    public String getVideoName()
    return videoName;
    public int getVideoQuantity()
    return videoQuantity;
    }

    Dear Bri81,
    Thank you for your reply.
    I tried the coding as you suggested
    while(i.hasNext())
    System.out.println( i.next() );
    but the error message reads:
    "CD.java": Error #: 354 : incompatible types; found: void, required: java.lang.String at line 35
    Your help is appreciated
    Norman
    import java.util.*;
    public class TryCD
       public static void main(String[] args)
         Vector cdVector = new Vector();
         CD cd_1 = new CD("Heavy Rapper", "Joe", true);
         CD cd_2 = new CD("Country Music", "Sam", true);
         CD cd_3 = new CD("Punk Music", "Mary", true);
         cdVector.add(cd_1);
         cdVector.add(cd_2);
         cdVector.add(cd_3);
         Iterator i = cdVector.iterator();
         while(i.hasNext())
           System.out.println( i.next() );
    public class CD
       private String item;
       private boolean borrowed = false;
       private String borrower = "";
       private int totalNumberOfItems;
       private int totalNumberOfItemsBorrowed;
       public CD(String item,String borrower, boolean borrowed)
         this.item = item;
         this.borrower = borrower;
         this.borrowed = borrowed;
       public String getItem()
         return item;
       public String getBorrower()
         return borrower;
       public boolean getBorrowed()
         return borrowed;
       public String toString()
          return System.out.println( getItem() + getBorrower());

  • I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    This can be the result of selecting the wrong driver. An older, unsupported laser printer will sometimes work with the generic Postscript driver.

  • I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?

  • Help me sort out the problems with Java 2 SDK SE

    I install Java SDK 2 standard Eddition version 1.4 in my computer (Window NT4). When I test the installation by typing in "java -version", it displays the following message.
    C:\JavaPractice>java -version
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    But, When I compile a simple programme, it doesn't work and displays the following message.
    C:\JavaPractice>javac HelloDan.java
    The name specified is not recognized as an
    internal or external command, operable program or batch file.
    Could anybody help me sort out the problem, Please?

    i might guess that you have j2sdk1.4.0\jre\bin on your PATH, but not j2sdk1.4.0\bin ...
    Larry

  • I use printopia to print from my iPad, trying to print out a 4 page credit card statement, but it only prints out the first page, please help

    I use printopia to print from my iPad, trying to print out a 4 page credit card statement, but it only prints out the first page, please help

    What version of iOS are you using?  Some people were having this problem before, and it was fixed when they updated to iOS 5.

  • HP 3050 how can I print out the printercod​e / e-mailadre​ss of the printer??

    HP 3050 XP/7
    For using the ePrintserviceI have to fill in the printercode / e-mailadress of the printer. How can I print out these informations. I already printetd out the Net configuration page (Netzwerkkonfigurationsseite) and the printerstatus (Druckerstatusbericht). I can find URL, Hostname but not printercode / e-mailadress.
    I´m not sure if I enabled the webservice of the printer.How can I check this setting and how can I enable webservice.
    Posts in German language would be great, but english is ok as well.
    THX very much!!

    Hello oli-b,
    The DeskJet 3050 does not have the Web Services feature which allows ePrint and the email address of the printer. The printer you would need is the DeskJet 3050A which includes these features.
    If this is what you have then you would need to connect your printer to the wireless network using the setup CD software that was included with the printer. Once you have successfully connected to the wireless network, there should be an ePrint button on the printer that allows you to access the Web Services menu and enable this feature and give your printer an email address for ePrint.
    Hope this helps.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • HT4356 I don't have wireless printer. How can I print out the document?

    I don't have a wireless printer. How can I print out the document from regular printer?

    iOS AirPrint Printers  http://support.apple.com/kb/HT4356
    How to Print from Your iPad: Summary of Printer and Printing Options
    http://ipadacademy.com/2012/03/how-to-print-from-your-ipad-summary-of-printer-an d-printing-options
    Print from iPad / iPhone without AirPrint
    http://ipadhelp.com/ipad-help/print-from-ipad-iphone-without-airprint/
    How to Enable AirPrint on a Mac and Use Any Printer
    http://ipadhelp.com/ipad-help/how-to-use-airprint-with-any-printer/
    iPad Power: How to Print
    http://www.macworld.com/article/1160312/ipad_printing.html
    Check out these print apps for the iPad.
    Print Utility for iPad  ($3.99) http://itunes.apple.com/us/app/print-utility-for-ipad/id422858586?mt=8
    Print Agent Pro for iPad ($5.99)  http://itunes.apple.com/us/app/print-agent-pro-for-ipad/id421782942?mt=8   Print Agent Pro can print to many non-AirPrint and non-wireless printers on your network, even if they are only connected to a Mac or PC via USB.
    FingerPrint turns any printer into an AirPrint printer
    http://reviews.cnet.com/8301-19512_7-57368414-233/fingerprint-turns-any-printer- into-an-airprint-printer/
     Cheers, Tom

  • Vendor payment with print out

    Hi,
    I am not able to make payment to the vendor through vendor payment with print out option as system is insisting me to input payment method, where as I have already given payment method "C" which is configured for that company code and country.
    Please suggest me why system is not allowing me to process the payment under this option.
    Thanks
    Ramesh.

    Hello
    I think you need to check all the configuration settings done for APP
    The list is in the link below
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/01/a9c079455711d182b40000e829fbfe/frameset.htm
    Reg
    *assign points if useful

  • How to print out the text for Info record in ME23?

    Dear all,
    I need to print out a report of PO data. need to print out the text from Info record note (like the picture shown below) in ME23, how should I pull that field and display out?
    I need the solution urgently. Hope experts can help.
    Thank you very much.
    [http://img293.imageshack.us/img293/238/inforecordnd1.png]

    Please check below sample code:
    PARAMETERS: p_ebeln TYPE ebeln OBLIGATORY.
    TYPES: BEGIN OF ty_ekpo,
             ebeln TYPE ebeln,
             ebelp TYPE ebelp,
           END OF ty_ekpo.
    DATA: i_ekpo TYPE TABLE OF ty_ekpo,
          wa_ekpo TYPE ty_ekpo.
    DATA: l_name TYPE tdobname,
          i_tline TYPE TABLE OF tline,
          wa_tline TYPE tline.
    CONSTANTS: c_id   TYPE tdid VALUE 'F02',
               c_object TYPE tdobject VALUE 'EKPO'.
    AT SELECTION-SCREEN.
      SELECT SINGLE ebeln INTO p_ebeln
             FROM ekko
             WHERE ebeln = p_ebeln.
      IF sy-subrc NE 0.
        MESSAGE e001(00) WITH 'Enter valid PO Number'.
      ENDIF.
    START-OF-SELECTION.
      SELECT ebeln ebelp INTO TABLE i_ekpo
             FROM ekpo
             WHERE ebeln = p_ebeln.
      LOOP AT i_ekpo INTO wa_ekpo.
        CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp
           INTO l_name.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            id                      = c_id
            language                = sy-langu
            name                    = l_name
            object                  = c_object
          TABLES
            lines                   = i_tline
          EXCEPTIONS
            id                      = 1
            language                = 2
            name                    = 3
            not_found               = 4
            object                  = 5
            reference_check         = 6
            wrong_access_to_archive = 7
            OTHERS                  = 8.
        IF sy-subrc EQ 0.
          LOOP AT i_tline INTO wa_tline.
            WRITE:/ wa_tline-tdline.
            " Format wa_tline-tdline in the way you need to print out
          ENDLOOP.
        ENDIF.
      ENDLOOP.
    Regards
    Eswar

Maybe you are looking for

  • How can I keep only the photos i like in my hard drive ?

    lets say i download 10 pictures from my camera to my library. i dont like five and send them to my trash bin. then i modify them all five and everything looks allright in my iphoto library. And then i go to my hard drive and i have 20 photos! but i o

  • PSE 7(edit) not working

    I use Windows Vista and PSE 7. Recently when trying to open PSE 7(edit) I get a message that Adobe PSE(edit) has stopped working. It also states that " A problem caused the program to stop working correctly. Windows will close the program and notify

  • Konica Minlolta Magicolor 2350 printer drivers for MacBook Air.

    Can anyone help me get these as I can only use a generic driver which means I can only print in black and white :-(

  • Photo's original date?

    Last year I saved my photos to an external drive, can't remember the method... whether I dragged the iphoto folder over or if I dragged individual folders. Now when I look at the thumbs the 'modified date' shows the date of the save but I can't find

  • Servlet background process on tomcat 4.0.2

    i have 1 servlet which will run a thread, background process, whenever the init() on that servlet called. i tried on tomcat 3.3a and tomcat 3.2.3, and both tomcat will run my servlet's background process, will run the thread. but, when i run the serv