Correct way to use double type to represent money quantities

I was assigned a project where I had to create a class that received money quantities as double numbers and that implemented a method returning a quantity of money as double. I have to use this scheme as we have no seen other data types in class.
My question is, what can I do to make sure that the value I'm returning is a double number that looks like money. For example, I don't want my method to return 10.78889332., I want it to return 10.79. How can I do that? Is there any intended method for that?
Can I let this issue like that and then take care of it in the test class by formating the output of the method when using it. I think this approach is not correct.
Thanks for your time.

See http://docs.sun.com/source/806-3568/ncg_goldberg.html
There is no correct way to use double type to represent money quantities. You shouldn't be receiving them, you shouldn't use them, and you shouldn't return them. Floating-point is for science, not money.
Use BIgDecimal.

Similar Messages

  • Checking on the correct way to use Time Machine

    Checking on the correct way to use Time Machine.
    Open Time Machine in Preferance, Click on options,
    The only item showing on list is my HD.
    Is that correct for every thing to be backed up or should I have other items showing.
    Also should my HD be deleated from this list.
    Await any help.
    Richard

    Richard. B Mann wrote:
    Checking on the correct way to use Time Machine.
    Open Time Machine in Preferance, Click on options,
    The only item showing on list is my HD.
    Is that correct for every thing to be backed up or should I have other items showing.
    no that's wrong. this is TM exclusion list. you add items there that you DO NOT want to be backed up. so currently your whole hard drive is excluded. remove it from there if you want it to be backed up. the only thing that should be present on that list by default is the TM backup drive itself.
    btw, see pondini's TM FAQs for more info on using TM
    http://discussions.apple.com/thread.jspa?threadID=1964018
    Also should my HD be deleated from this list.
    Await any help.
    Richard

  • Correct way to use AXL API with complex types css, partition, etc. involving: JAXBElement XFkType ?

    I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
    https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
    ...to use complex types (partition, css, etc). 
    --> What is the correct way to do it?
    Example 1: UpdatePhone
    When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
    his function is not working:
    public void actualizarPhone(LPhone lPhone) {
            try {
                UpdatePhoneReq axlParams = new UpdatePhoneReq();
                axlParams.setName(lPhone.getName());
                axlParams.setDescription(lPhone.getDescription());
                axlParams.setDevicePoolName(lPhone.getDevicePoolName());
                axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
                StandardResponse response = axlPort.updatePhone(axlParams);
                //return response.getReturn()a.toString();
            } catch (Exception e) {
                logger.error(e);
                //return new ArrayList<LPhone>();
    It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
    but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
    Example 2: AddLine
    I also have this problem when adding line. 
    And I've tried at least 3 approaches, no success yet:
    1)** Using factory object to obtain an R object
    ObjectFactory factory = new ObjectFactory();
    RRoutePartition rRoutePartition = factory.createRRoutePartition();
    rRoutePartition.setName("autodial");
    2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
    JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
    jaxbElement.setValue(partition3);
    line.setRoutePartitionName(jaxbElement);
    3)** Using X Objects
    XCallForwardBusy fwdBusy = new XCallForwardBusy();
    fwdBusy.setForwardToVoiceMail("true");
    AddLineReq newLine = new AddLineReq();
    XLine line = new XLine();
    line.setAlertingName("ALerting Name");
    line.setAsciiAlertingName("Alerting Name ASCII");
    line.setCallForwardBusy(fwdBusy);
    line.setDescription("Description");
    line.setPattern("5555");
    I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
    regards!

    I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
    https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
    ...to use complex types (partition, css, etc). 
    --> What is the correct way to do it?
    Example 1: UpdatePhone
    When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
    his function is not working:
    public void actualizarPhone(LPhone lPhone) {
            try {
                UpdatePhoneReq axlParams = new UpdatePhoneReq();
                axlParams.setName(lPhone.getName());
                axlParams.setDescription(lPhone.getDescription());
                axlParams.setDevicePoolName(lPhone.getDevicePoolName());
                axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
                StandardResponse response = axlPort.updatePhone(axlParams);
                //return response.getReturn()a.toString();
            } catch (Exception e) {
                logger.error(e);
                //return new ArrayList<LPhone>();
    It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
    but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
    Example 2: AddLine
    I also have this problem when adding line. 
    And I've tried at least 3 approaches, no success yet:
    1)** Using factory object to obtain an R object
    ObjectFactory factory = new ObjectFactory();
    RRoutePartition rRoutePartition = factory.createRRoutePartition();
    rRoutePartition.setName("autodial");
    2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
    JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
    jaxbElement.setValue(partition3);
    line.setRoutePartitionName(jaxbElement);
    3)** Using X Objects
    XCallForwardBusy fwdBusy = new XCallForwardBusy();
    fwdBusy.setForwardToVoiceMail("true");
    AddLineReq newLine = new AddLineReq();
    XLine line = new XLine();
    line.setAlertingName("ALerting Name");
    line.setAsciiAlertingName("Alerting Name ASCII");
    line.setCallForwardBusy(fwdBusy);
    line.setDescription("Description");
    line.setPattern("5555");
    I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
    regards!

  • Correct way of using LayeredPane for animation

    Hi,
    before I post my questions some background info (it has become quite a long story sorry for that, you can skip to the bottom if you want):
    i'm not an expert java programmer so I appologize for any stupid questions or remarks.
    Currently i'm implementing a road traffic simulation. Cars drive over roads, intersections etc. To make the movements/animation look smooth i've used doublebuffering or page flipping (I'm not sure while I used the getBufferStrategy() from a JFrame: strategy = frame.getBufferStrategy(); )
    To add my own JButtons created from .png file I've switched off the RepaintManager by creating a NullRepaintManager. The simulation thread is responsible for calling the repaint function, which is done every few milliseconds after the positions of the cars are updated. These buttons are added to the ContentPane of the frame which is made non-opaque to make the roadnetwork and cars visible (*i don't understand this)
    Btw I've 'borrowed' these ideas from 'developing games in java ' from Brackeen: http://www.brackeen.com/javagamebook/
    The roadnetwork and cars are drawn on the a Graphics2D by calling: (Graphics2D)strategy.getDrawGraphics(); first I draw an image of the roadnetwork to clear the old vehicle positions and then the new positions of the cars are drawn. after that the screen/frame is updated: strategy.show();
    This all works fine.
    The problems start when I want to have a popup JPanel to appear on the screen after I clicked somewhere on the roadnetwork. According to Brackeen this can be done by initializing a JPanel and add it to the LayeredPane of the JFrame and make it visible when needed. This does not work while the JPanel never pop's up and I don't understand why not, because the demo from brackeen works fine. When I add this JPanel to the contentPane it does popup but the buttons are shifted to the right which is not what i want.
    Also I want to add a JMenuBar to the frame, i thought I could simply used: frame.tsetJMenuBar(menuBar);
    however the menubar shows up next to my custom JButtons....
    ====>My Questions:
    What is the correct way to draw smooth animations inJava without slowing down the whole program when quite a large area has to be draw... this seems to happen e.g. in the Java demos: ..\jfc\Java2D
    How can I popup JPanels or internalFrames ontop of the animation?? probably by using the LayeredPane?
    I also want to add a JMenuBar in the normal position.
    Sorry for the long text and questions... but I'm struggling for almost two month with this now (using an increadible number of java books) and haven't solved it yet.
    Any suggestions are welcome Thanks in advance!!
    Rens

    It gets the first address from the pxelinux.0, another one is usually handed down after it boots, but sometimes it reuses it again. 
    Usually what happens on a diskless system is it tries to use the dhcpcd lease from the last diskless workstation (or possibly reuses the same one it gets from pxelinux.0).  But it has enough logic built into that it looks for another unique address for the next diskless workstation. 
    Do you have your pxeclient.cfg/default appended options set correctly to be ip=::::::dhcp? 
    Of course from the diskless wiki:
    label archxx
    kernel archxx/boot/vmlinuz-linux
    append init=/usr/lib/systemd/systemd initrd=archxx/boot/initramfs-linux.img root=/dev/nfs rootfstype=nfs nfsroot=xx.xx.xx.xx:/srv/tftp/archxx,v3,rsize=16384,wsize=16384 ip=::::::dhcp

  • What is the correct way to use Version Informatio​n from the sequence and from the deployment tool

    I seem to be missing something in how the various version numbers are supposed to be used.    My end goal is to log and possibly display in the UI the version of the sequence and which installer version was used to inspect a UUT.   I have gotten most of the way there using:
     How Can I Programmatically Query the Sequence File Version of My TestStand Sequence? 
    and logging this into the report with a function which contains:
    Parameters.UUT.AdditionalData.SetValString("Test Version",1,RunState.SequenceFile.Data.Version),
    Parameters.UUT.AdditionalData.SetFlags("",0,PropFl​ags_IncludeInReport)
    The "Deployment Version" in the TestStand Deployment Utility auto incrementing the 3rd position of a version number  while the sequence auto increment is working on the 4th.   
    My first question is are these 2 version numbers in anyway supposed to be related to each other?   As it seems to me you would want those 2 reversed, I can make several installers based on sequence version X, making changes to what supporting files are also installed.
    If they are not related as I suspect that they are not.  How do I programatically grabed the installer version and also log that into the result report?   
    is there an option to perform a custom deployment build step to log the deployment version before it builds and then reference that log at runtime of the test?

    Hi,
    The sequence file version and deployment versions are not related.
    You can build the installer with whatever version you want using the command line :
    https://decibel.ni.com/content/docs/DOC-38947
    Hope this helps,
    Ravi

  • Correct way to use SSL?

    I have just implemented a SSL certificate on my site. By
    default, site
    striucture is such that I have a HTTPDocs foder where I keep
    all my web
    pages etc but I also have a HTTPSDocs folder which is empty.
    The HTTPSDocs folder appears to be a mirror of the HTTPDocs
    folder, in that
    I do not need to manually put webpages that I wish to be
    secured into the
    HTTPS folder. In fact if I put the pages I want to be secured
    in the
    HTTPSDocs folder then the browser cannot find these pages.
    So, I have left all the pages etc. in the HTTP folder and for
    the pages I
    want secured I have linked from the form on the previous page
    by the full
    name eg. https://www.mysite.com/securepage.asp instead of
    just
    ../securepage.asp as it was before and this works fine. To
    leave the
    security I do the opposite eg.
    http://www.mysite.com/exitsecurepage.asp
    and
    this takes the browser back to a non-secured state. (the
    above links are
    dummy links)
    Is this the correct way to handle SSL?
    Thanks.

    Well, Is it???
    "GrantB" <[email protected]> wrote in message
    news:f0vieu$eeh$[email protected]..
    >I have just implemented a SSL certificate on my site. By
    default, site
    >striucture is such that I have a HTTPDocs foder where I
    keep all my web
    >pages etc but I also have a HTTPSDocs folder which is
    empty.
    >
    > The HTTPSDocs folder appears to be a mirror of the
    HTTPDocs folder, in
    > that I do not need to manually put webpages that I wish
    to be secured into
    > the HTTPS folder. In fact if I put the pages I want to
    be secured in the
    > HTTPSDocs folder then the browser cannot find these
    pages.
    >
    > So, I have left all the pages etc. in the HTTP folder
    and for the pages I
    > want secured I have linked from the form on the previous
    page by the full
    > name eg. https://www.mysite.com/securepage.asp instead
    of just
    > ../securepage.asp as it was before and this works fine.
    To leave the
    > security I do the opposite eg.
    http://www.mysite.com/exitsecurepage.asp
    > and this takes the browser back to a non-secured state.
    (the above links
    > are dummy links)
    >
    > Is this the correct way to handle SSL?
    >
    > Thanks.
    >

  • Is there a way to use touch type tool in CS6 ? i cant find it

    im using illustrator CS6 and i cant find Touch Type Tool! is there a way to upgrade or load it ??

    Touch type is only available in CC.
    Mylenium

  • What's the correct way to use "Relocate Masters?"

    I have 100GB of master images on one drive. Twenty gigs of those photos are imported into Aperture already (I use the referenced masters method), and I will be importing the remaining 80 gigs eventually (all referenced). For now I need to move all 100 gigs to another drive. How should I do this in Aperture?
    Is "relocate masters" just for the images already imported and part of my Aperture library? Should I just drag and drop the other 80 gigs that are not yet imported? What procedure would you use to accomplish what I need to do? Thanks.

    No, the best way would be to run relocate masters first and let Aperture move the images that are already imported into it.  When that's done drag whats left.
    If you drag all the files over Aperture will lose track of the ones imported into it ad you will have to run reconnect master rather than relocate master and while reconnecting works it's not as easy as relocate.

  • Correct way to use an external hard drive

    Hi, I just wanted to ask for a word of caution and wisdom before proceeding with using external HD for the first time.
    My 320GB hard drive is finally filling up (mainly with music, photos, and videos), so just purchased a LaCie 2TB D2 Quadra to use as
    a) time machine to backup whatever I have in my computer. (is it possible to use time machine to backup data on the external HD as well, or only the data in my computer HD?)
    b) storing, backup, and live editing of photos and videos.
    My main objective is to leave as much free HD space as possible in my computer HD and just use external HD for mostly everything. However, my concern would what to do when/if the external HD fails...
    What would be the most ideal solution for my simple and novice situation? Suggestions or recommendations would be greatly appreciated.
    Thanks.

    I think I should start with the caveat "all drives can fail" and that any solid backup strategy involves more than one drive and/or a regime of burning critical data to DVD regularly.
    In your scenario your best approach would be to partition the 2TB into several volumes; perhaps a couple for backup, one for scratch use and another for specific types of data - it wont hurt to have 5 or 6 in play.
    Yes you can set any volume as a time machine backup volume of any other drive (space permitting of course)
    I still come back to the original warning that anything can fail and for mission critical data it would be wise to have another drive as 2nd or 3rd Tier backup.

  • Correct way to use an event handler

    The following is dynamically adds a series of buttons and a label to each button. The problem is that the event handler fires twice for each button, and the last button never gets processed at all.
    Should I be using a different event handler than ResizeEvent.RESIZE? How do I add the label to the last button in the sequence?
    Thank you.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
        <mx:Script>
      <![CDATA[
          import mx.events.ResizeEvent;
    private var button:Button2;
    public var numButtons:Number=5;
    private var counter:Number=0;
    public function init():void{
        for(var i:int=0; i<numButtons;i++){
            button=new Button2;
            hbox.addChild(button)
            button.addEventListener(ResizeEvent.RESIZE, handleButtonAdded)
    private function handleButtonAdded(e:ResizeEvent):void{
        counter++
        trace(e.target)
        e.target.label= String(counter);
        button.removeEventListener(ResizeEvent.RESIZE, handleButtonAdded)
      ]]>
    </mx:Script>
    <mx:HBox id="hbox"  horizontalGap="0"/>
    </mx:Application>
    Here's the button: Button2.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" >
    <mx:Script>
        <![CDATA[
        public function init():void{
            this.width=100;
        ]]>
    </mx:Script>
    </mx:Button>

    Hmm , what are you trying to do ?  There are a few questionable things happening.  Your event-handler is named "handleButtonAdded" but it takes a ResizeEvent ? Do you mean to trigger an event based on when the button was added to the stage , or parent such as FlexEvent.ADDED or when the creation is complete ,  FlexEvent.CREATION_COMPLETE ?
       The second thing is your "button" variable.  It is declared outside of the loop in the "init" function.  Meaning , when that loop is done and even during execution , it will point to the last button created.  So all the buttons have listeners , meaning when one button fires off a ResizeEvent , it will remove the listener for whatever your variable "button" is pointing to.  This guarantees (well , maybe not) the behaviour that your last button will NOT have a listener , therefore it will not fire.
      By the way , you can set the label and the size of the button when you declare them. You don't have to subclass and use listeners.

  • Correct way to use transparency with shapes to avoid darker on overlap

    I am trying to draw some semi-transparent shapes (circles, rectangles, etc) in Java2D. I am using the AlphaComposite.SRC_OVER rule
    My problem is some of these shapes overlap - where they overlap, the colour appears darker. I want to avoid this effect.
    Is there a way to avoid this.

    nevermind
    Edited by: Maxideon on Mar 12, 2009 2:39 PM

  • Correct way of using Packages in the application

    Hi,
    I would like to know if there is any performance loop hole if i use old developed packages in my current project?
    Will there be any problems with the oracle memory structures like lib cache,dict cache and buffer cache?
    Example:
    I have Packages A,B,C,D
    Now i will develop package E, in package E, i want to utilize the old developed business librarys i.e A,B,C,D in E
    i.e PACKAGE E AS
    BEGIN
    A.method();
    B.method();
    C.Method();
    D.Method();
    END;
    If there will be the performance problems can i develop the same functionality which is there in the previous one in the existing package?
    Thanks!!
    VJ

    Hello VJ,
    that's what packages are made for: to be reused. On the other hand, if you use only a small part of the code in the "old" packages it might be useful to extract this code, but only for maintainance reasons. Any developer will be glad if he doesn't have to search 5000 lines of code only to maintain the 100 lines that are used.
    So in my opinion the question is: will the procedures/functions of the old packages have to be kept in sync for more then one application, than just reuse them. Do you use most of the code in the packages then just reuse them. If you use only a small part of the code then consider extracting it, but only for maintainance reasons.
    Or does old mean that the packages are inefficient? Otherwise they are not old but as young as ever.
    Regards
    Marcus

  • Could someone show me the correct way to use the Vector in the code below?

    Would someone mind explaining to me why I am getting a NullPointerException when I run the code below? I initialized the vector in the constructor so it should follow through the whole class right? What would be the right way to do it?
    import java.util.Vector;
    public class AlumniDirectory
        private String faculty;
        private static Vector alumni;
        /** Constructor reads faculty Name and inits new vector **/
        public AlumniDirectory(String facultyIn)
            Vector alumni = new Vector();      
            faculty = facultyIn;      
        /** Method adds a new Alumni to the list **/
        public void addAlumnus(Object o)
            alumni.addElement(o);
        /** Method removes a Alumni from the list **/
        public void removeAlumnus(Object o)
            alumni.removeElement(o);      
        /** Method searches for Alumni by last name and graduation year **/
        public void searchAlumnus(String lastNameIn, int years)
          // Code will go here eventually  
        }

    And probably you want a list of Alumni not a vector of Objects. So try this:
    import java.util.List;
    import java.util.ArrayList;
    public class AlumniDirectory{
        private final String faculty;
        private final List<Alumnus> alumni = new ArrayList<Alumnus>();
        /** Constructor reads faculty Name and inits new vector **/
        public AlumniDirectory(String facultyIn)
            faculty = facultyIn;      
        /** Method adds a new Alumni to the list **/
        public void addAlumnus(Alumnus alumnus)
            alumni.add(alumnus));
        /** Method removes a Alumni from the list **/
        public void removeAlumnus(Alumnus alumnus)
            alumni.remove(alumnus);      
        /** Method searches for Alumni by last name and graduation year **/
        public void searchAlumnus(String lastNameIn, int years)
          // Code will go here eventually  
        }-Puce
    Edited by: Puce on Oct 23, 2007 7:43 PM
    Edited by: Puce on Oct 23, 2007 7:46 PM

  • Is it the correct way to  use setrolloverenabled  in JButton()  ??

    i am unable to create rollover icons for the Jbuttons. The program isnt showing any errors but its not displaying rollover icons. Should i add anything extra for the code below ?? pls check the code below
    public void createGUI()
    setLayout(new FlowLayout());
    b1=new JButton("Submit");
    b1.setRolloverEnabled(true);
    b1.setRolloverIcon(new ImageIcon("warning.gif"));
    add(b1);
    this method is written in class extending JApplet
    Thanks for all replying

    May be it has something to do with the image path.
    Did you check other possible options, say making use of the absolute path and all that? [http://www.leepoint.net/notes-java/GUI-lowlevel/graphics/45imageicon.html]

  • Correct Way to use Bind variables when using an MS SQL server backend

    Hey,
    I'm having some trouble figuring out how to use bind variables in a view when using an MS SQL server backend. For some reason when I'm using an ApplicationModule that has a MS SQL Server JDBC library loaded and I attempt to click OK when editing the following query:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = :1
    I get an error stating that "SQL Query Error Message Incorrect Syntax near ':'". Is JDeveloper compatible with SQL server for bind variables because this query runs just fine if I replace the :1 with a say "Testing testing".
    Thanks in advance
    Edited by: NullCheck on Dec 15, 2010 2:06 PM

    Gotcha. I had tried %1% %0% ?0 and ?1 and various other permutations none of which worked. Got it working by setting the query to:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = ?
    ORDER BY kit_status
    And then adding a bind variable with "Bind position" set to 0.
    Thanks again Shay!

Maybe you are looking for

  • Installed Panther on Older iMac and Mail Doesn't Work Correctly

    I installed panther on my son's iMac recently. I created a subaccount for him from my verizon dsl account. I made sure all the info was the same on my mail preferences as in his but we can't send or received anything. I keep getting a message to put

  • Do iphoto journals save to icloud?

    I currently have iPhoto installed on my iPad 2 I also have an iPhone 3GS which means the app is not compatible with my phone. When you create journals in the iPhoto app, do these save to the icloud? i.e. if I had a phone compatible with the iPhoto ap

  • Form not displaying primary key field

    I create a form and the primary field is not displayed???

  • Mass order Confirmation

    Hi all, During multiple order confirmation using CO1V , how can I post goods movements also. I tried clicking on the goods movement button and enter all the details, but when I try to save the save button is greyed out. So I hit the back button and c

  • Timer function

    May i know how to use the timer function in labwindows so that i can read a value from my 6024E card very 2ms? what is the program to write in order to achieve this?