New question....adding decimal places...

Ok my assignment is thus:The Lone Oak High School Marching Band is raising funds by selling fruit. In order to simplify processing of orders, only three types of packages of fruit are being sold. They are
Box of Apples at a cost of $14.00
Box of Peaches at a cost of $16.00
Box of Oranges at a cost of $18.00
There is a 10.00% tax on the total order amount. Write a Java program that reads the number of each type package on an order and computes the cost for the packages of each type ordered. Total the order, calculate the tax on the order, and the total including the tax. Print all items read and all items calculated with appropriate labels.
Example:
Boxes of Apples: 2
Boxes of Peaches: 3
Boxes of Oranges: 4
Total cost of the fruit: 148.00
Tax: 14.80
Total Amount Due: 162.80
Now ive got the program to work exactly as it should but for neatness i want it to have 2 decimal places. When it runs, ill use the above as an example, it cuts off the second decimal. Is there a nice way to add the the second decimal place?
Edited by: chaoticglee on Jan 30, 2008 3:40 PM

Try this as an example:
import java.util.Scanner;
import java.text.DecimalFormat;
public class ex
    final static double HOTDOG_COST = 10.00;
    final static double TAX = 0.05;
    public static void main(String[] args)
        DecimalFormat money = new DecimalFormat("$0.00");
        Scanner in = new Scanner(System.in);
        System.out.print("How many hotdogs do you want? ");
        double subTotal = in.nextInt() * HOTDOG_COST;
        double taxCost = subTotal * TAX;
        double total = subTotal + taxCost;
        System.out.println("Cost of food: " + money.format(subTotal));
        System.out.println("Tax: " + money.format(taxCost));
        System.out.println("Total: " + money.format(total));
}

Similar Messages

  • Question about decimal places for currencies

    hi ,experts ,
       here is the problem , when i use mb5s, i found the net price has been enlarged 1000 times . I  also found the data of the table EKPO has been enlarged 1000 times. So ,i check the decimal places for currencies , i found there are five decimal places , the standard system is two decimal places . 
       Does this mean that we cann't  change the decimal places in SAP?  If we can change , what should we do for configuration ? 
    Jarod

    When running OY04, you are receivingin the following message:
    Before you continue, please read the following        
    text carefully.                                       
    If you do not heed this note, you can cause
    irreparable damage to the system with this            
    transacton.                                           
    In the R/3 System tables currency fields are          
    stored as decimal figures with a variable number      
    of decimal places. The decimal point is not           
    stored in the field in the database. Instead,         
    each currency field refers to a currency key          
    field. In this transaction you assign the number      
    of decimal places to this currency key uniquely.      
    Example: If you have set currency USD to have         
    two decimal places and you post an amount of 100      
    USD, an amount of 10000 USD is stored in the          
    Do you want to change the decimal places despite      
    all recommendations?

  • Question about decimal places

    Guys,
    When I do the "Normalization of Result" and make "Number of Decimal Places" as 0.00.  The result still gives me 100.000%.  Is there a way that i can make it 100.00%?
    Thanks,
    RG

    Hi Ram,
    As shown in the properties itself in "Number of Decimal Places" --> (From Keyfigure: 0.000), it is the default thing provided by SAP. Try giving different things for "Scaling Factor" too along with "Number of Decimal Places", you may achieve your required thing.
    Regards,
    KK.

  • Adding Decimal Place

    Dear Guru
    I want to add 5 digits after decimal in my pricing condition types.Pls suggest how to make this settings
    Thanx
    MK

    Dear MK,
    The transaction OY04 is the correct to define decimal places based on currency. However, before you
    made the changes, please kindly make sure you don't have existing or not completing purchasing document
    in your system as this will affect the document that may create inconsistency later.
    BR,
    Ian

  • How to use batch mode in cq dam - new questions added

    Hi I am doing DAM migration. I am using custom code to pick the image and create asset by calling Assetmanager.createAsset which creates dam assets.
    This code I am calling through the scheduler which will run for every 0.5 hr. Around 1000 images we are trying to push in each cycle. I came acrosss batchMode for saving all the images per batch so that it will reduce the migration time But I am not sure how to use it.
    .setBatchMode(true); isBatchMode are the methods available in Asset api.
    Please share your thoughts on this.
    Some more Point I want to ask.
    1.What is the best appraoch when we are pushing images to DAM
         Stopping the workflows push all the images and run the work flows. (Is it possible to do this?)
         Do the both simultaniously
         Do it in the bath (i.e push bunch of images and then run the workflows)
    2.When i am migrating images (from file system which is residing in the same box where cq is running )it is almost taking 0.5 hr for 1000 images (avg size of image is 100kb). Is there any possibility to      improve this process.
    3. When I am adding images I am adding subassets to some of the images so when ever I add subasset cq is creating new version of the asset which is not required for me. What is the best approach to avoid      creating too many versions for images in DAM. By doing this is there any performance improve in the system.
    Thanks,
    Maruthi

    Hi Jorg,
    Thank you.
    I will try out batch saving option.
    I have few more doubts.
    1. Today I tried for moving aroung 5k images through the scheduler in my local machine. It went smoothly with out much issues but as usual some of the renditions are failing for some of the sub assets. This is about 3 for every 10 images. Renditions are generating properly for all assets it is failing in case of sub assets only. Along with this I am getting version exceptions. Below are errors which I am facing very frequently during migration dry run. This seems to be beacuse of the non synchronized execute methods in WF steps. What is your call on these issues how can we avoid these kind of errors.
    20.02.2013 19:16:00.082 *ERROR* [JobHandler: /etc/workflow/instances/2013-02-20/model_1361367956960012000:/content/dam/<IMAGE PATH>/subassets/<Image Name>/jcr:content/renditions/original] com.day.cq.dam.core.impl.AssetImpl setRendition: cannot set new rendition [cq5dam.thumbnail.140.100.png] for asset [<IMAGE PATH>/subassets/<Image Name>]:  javax.jcr.version.VersionException: Unable to perform operation. Node is checked-in.
    20.02.2013 19:17:01.660 *ERROR* [JobHandler: /etc/workflow/instances/2013-02-20/model_1361368020884400000:/content/dam/<IMAGE PATH>/jcr:content/metadata] com.day.cq.dam.core.impl.handler.xmp.NCommXMPHandler Stack Trace: java.lang.Exception: Unable to create revision.
    Caused by: javax.jcr.RepositoryException: Unable to update item: item.save()
    Caused by: javax.jcr.InvalidItemStateException: Item cannot be saved because it has been deleted externally: item.save()
    20.02.2013 19:19:08.666 *WARN* [JobHandler: /etc/workflow/instances/2013-02-20/model_1361368144852589000:/content/dam/<IMAGE PATH>/subassets/<Image Name>/jcr:content/renditions/original] com.day.cq.dam.core.process.ExtractMetadataProcess unexpected error occurred during metadata extraction. Cause: Unable to perform operation. Node is checked-in. javax.jcr.version.VersionException: Unable to perform operation. Node is checked-in.
    2. Can you share about experience in DAM migrations. What is the avg time it takes for migrating about 1 to 1.2 lac images which are aroung 60    gig. We thought of running the scheduler (this.scheduler.addPeriodicJob(jobName, job, config, period, canRunConcurrently);)for every 0.5 hr in  that case it will go on for 3 days.

  • BUG: Inputting decimal places into new duration preferences (Premiere Pro 2014.2)

    So, I checked the release notes for the newest version of Premiere Pro CC (2014.2). I was happy to see the ability to switch between frames and seconds when choosing the default durations of transitions and still images.
    Immediately found a bug. Decimal places don't work correctly after switching units.
    Open Preferences.
    Switch Video Transition Default Duration units from the default Frames to Seconds. Try to insert a decimal place using the keyboard. It doesn't work.
    Hit OK to close the Preferences, with Video Transition Default Duration now set to seconds
    Open preferences again and change the units back to frames. Now try to input decimal places. No matter where the text cursor is, the decimals just get added to the end of the form field.
    This seems to affect all three form fields (not just Video Transition, but Audio and Still Frame as well).
    Really weird bug, and I'm not sure how you guys at Adobe missed this one...
    Anyone else having this bug? I'm on Windows 7.
    If so, can someone please file an official bug report? I'm at work and low on time, but I felt like I needed to bring this up to make sure I'm not the only one in this boat.

    I've reproed this issue and logged a bug report.
    A workaround is to toggle the Unit setting, click Okay to close Preferences, then reopen Preferences and adjust the Value. Sorry for the inconvenience.
    I urge you to submit your own bug report (Adobe - Feature Request/Bug Report Form). The more customers who report an issue, the higher the odds that a fix will make it into the next release...

  • HT201303 I have a new ipod added to existing laptop itunes account it is now asking a security question i have not answered help

    I have a new ipod added to existing laptop itunes account it is now asking me a security question I have not answered - can anyone help please ?

    Click here for information. If the option to have the answers emailed to you isn't available or doesn't work(the email may take a few hours to arrive), contact the iTunes Store staff via the link in that article.
    (88450)

  • Set Decimal Places in a swing

    Ok so i know how to set decimal places in a applet and a command prompt type build but in a GUI i am trying to set them and it isnt working my code is:
    doc.insertString(doc.getLength(), strFICA[j] + "\t", textPane.getStyle("regular"));
    i went and added the information
    Decimal Format twoDigits = new Decimal Format("000.0");
    doc.insertString(doc.getLength(), twoDigits.Format (strFICA[j]) + "\t", textPane.getStyle("regular"));
    it gives me the error cannot find symbol
    symbol: method Format(java.land.String)
    Lacation: Class java.text.DecimalFormat
    doc.insertString(doc.getLength(), twoDigits.Format (strFICA[j]) + "\t", textPane.getStyle("regular"));
    ^
    what does this mean and help will be great

    Help given here is voluntary and people do try hard, but your questions are as unintelligible as they are naive. You really need to do some ground work first by reading the tutorials and trying things out for yourself before posting here.
    Those that get the most help are those that demonstrate they are willing to help themselves more than you seem to be.

  • The decimal place is wrong in GR55

    Dear Expert:
    We are using currency JPY
    We now creating a new report using report painter, but unfortunately the decimal place is wrong,
    the result is only one percentage of the real amount, how can I get this issue solved?
    notice that we are using report painter, not ABAP programming, so function module BAPI_CURRENCY_CONV_TO_INTERNAL
    is not applicable.

    Dear Lu Meng
    I was reading your question which seems not answered at all.
    I have EXACTLY your same issue.
    In ECC using a FAGLFLEXT Report Painter.
    My zero decimal currencies such as HUF and JPY are showing in the report, with decimals, thus are factor of 100 too small. Even changing layout deimcals, etc has NO EFFECT.
    Did you solve this sissue? OSS has nothing either?
    Thanks for any assistance.
    Richard

  • Query regarding decimal places for currencies

    Dear all,
    SAP standard allows 2 decimal points as default for any condition value. However, based on the entries in TCURX table we can set number of decimal places with reference to specific currencies.
    In our system there is no entry in TCURX table against USD currency. Still the system is taking 3 decimal places against the expected 2 decimal places.
    Is there somewhere hardcoded this for US or are they any additional settings impacting this? Please help
    Regards,
    Rajesh

    Hi All,
    I have been trying to set 3 decimal places. I got the reference to Note # 38881.
    This is what I did:
    1. Create a new currency US$ and set the decimal places to 3
    2. Maintained the prices using VK11.
    3. Changed the customers' sales area currency to US$
    But when I created the sales order although the system determined the prices in 3 decimals i got the following information message which keeps on showing during the entire sales order creation:
    Pricing error: Mandatory condition ZMAC is missing
    Message no. V1801
    Details are as below:
    The obligatory condition ZMAC does not exist. The document is therefore considered to be incomplete from the point of view of pricing.
    The cause can be, for example, that a condition record does not exist for condition ZMAC or that a field overflow has occurred when the condition rate was calculated.
    Procedure
    Check why the condition could not be found. Use the pricing analysis function on the pricing screen to do this. If necessary, add the missing condition manually to the document.
    I believe I am missing some configuration that should be done in pricing, not sure what. As this question has been flagged answered, hope someone would be able to help me.
    Thanks & Regards,
    Rajesh Singh

  • 11g Client - Inconsistencies at the 16th decimal place

    In TOAD, SQLPlus, & ODBC clients numbers returned from a query are correct (max 3 decimal places)
    In Discoverer & from a report, the numbers are off at the 16th decimal place...
    EG:
    7.081 becomes 7.0810000000000004
    7.090 becomes 7.0999999999999994 (which is exceptionally weird because the rounding doesn't work)
    7.200 becomes 7.2000000000000002
    Any idea what would cause this?
    How can I query from SQLPlus (or TOAD) to confirm whether or not those extended decimal places actually exist in the table?

    Alan3 wrote:
    Maybe I should have added this little tidbit...Please be as verbose as possible (feasible). Show queries etc. - use copy and paste.
    The particular table in question is an interface table that has been in place for 4+ years.
    The columns in question are of data type NUMBER.
    We just switched the PC that runs this interface to Win7 with an 11g client.Describe the interface. E.g. In what program language is it written?
    Now we see the extended decimals with Discoverer (on any PC) and the interface report (an old report built from developer 6) as well, but not from SQL, etc...How is changing one pc client related to the Discoverer and Reports reports? Has the database server been upgraded also? (full version from select * from v$version; )
    Do you see the same change for "old" data (from before the switch).
    I want to know if there is a setting in SQLPlus or the DB client that limits the display of the decimal places that I can alter to determine if the extended decimals actually show up... (they shouldn't be there at all)Both sqlplus and db may affect the outcome, e.g.
    SQL> desc test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  NUMBER(38,5)
    SQL> show numw
    numwidth 10
    SQL>
    SQL> select * from test;
             A          B
         12345      12345
    123456789  123456789
        123,45     123,45
    123,456789  123,45679
         1,234      1,234
    1,23456789    1,23457
    6 rows selected.The same values was inserted to both columns of test. With scale = 5 for its datatype, B values are rounded (4th and 6th row).
    SQL> set numw 5
    SQL> select * from test;
        A     B
    12345 12345
    123,5 123,5
    123,5 123,5
    1,234 1,234
    1,235 1,235
    6 rows selected.The numwidth setting affects sqlplus formatting.
    Edited by: orafad on Jan 5, 2011 9:44 PM

  • Currency Conversion Cuts off at 10 decimal places

    Hello all,
    When doing currency conversions the database cuts off the data two the 10th decimal place.  I need to be at 12 decimal places.  In the database the setting is set at decimal(25,10).  Is there a way to change it so the database will go out to more decimal places?
    Thanks for your help
    Steve

    It is possible to change the format to accept larger values, however this change will only impact any newly created Applications.
    To change the default, open Administrator and select "Set Application Parameters"
    Add the KeyID "SIGNED_DATA_FORMAT" and for the Value enter the total number of digits and the number of decimals, ex: "20,15" would indicate 20 digits to the left of the decimal and 15 to the right.
    Click on Update.
    Any new Application created will now use this new value for the Signed data column.
    I hope this helps in answering your question.

  • Determine Number of Decimal Place using BigDecimal

    I was interested to have the following getNumberOfDecimalPlace function :
    System.out.println("0 = " + Utils.getNumberOfDecimalPlace(0)); // 0
    System.out.println("1.0 = " + Utils.getNumberOfDecimalPlace(1.0)); // 0
    System.out.println("1.01 = " + Utils.getNumberOfDecimalPlace(1.01)); // 2
    System.out.println("1.012 = " + Utils.getNumberOfDecimalPlace(1.012)); // 3
    System.out.println("0.01 = " + Utils.getNumberOfDecimalPlace(0.01)); // 2
    System.out.println("0.012 = " + Utils.getNumberOfDecimalPlace(0.012)); // 3
    I use the following code
        public static int getNumberOfDecimalPlace(double value) {
            final BigDecimal bigDecimal = new BigDecimal("" + value);
            final String s = bigDecimal.toPlainString();
            System.out.println(s);
            final int index = s.indexOf('.');
            if (index < 0) {
                return 0;
            return s.length() - 1 - index;
        }However, for case 0, 1.0, it doesn't work well. I expect, "0" as result. But they turned out to be "0.0" and "1.0". This will return "1" as result.
    0.0
    0 = 1
    1.0
    1.0 = 1
    1.01
    1.01 = 2
    1.012
    1.012 = 3
    0.01
    0.01 = 2
    0.012
    0.012 = 3
    Any solution?

    Please [don't cross-post!|http://stackoverflow.com/questions/2296110/determine-number-of-decimal-place-using-bigdecimal], it's considered rude. If you must do it, then at least link each post so that people can find out which answers you've already got in order to avoid duplicate work on our part.
    Please read [_How To Ask Questions The Smart Way_|http://www.catb.org/~esr/faqs/smart-questions.html].

  • Reg: Decimal Places

    Hi,
    I have an amount Key Figure. Currently, it is pulling 2 decimal places. Even if I define the no. of decimal places in the BEx Tab to be 0.0000 or 0.000 or Undefined etc, it is still pulling 2 decimal places.
    A new requirement has come whereby from R3, we should be pulling 3 decimal places.
    How should this be incorporated in BI as whatever changes I am making, it is only pulling 2 decimal places?
    Kindly suggest.
    Regards,
    Anjana

    Is that happening for all the Key Figures in the system having the same unit. This is amount KF as you have mentioned that I believe that you would have either USD, INR, GBP etc.
    Question: is this happening only for specific Key Figure or all the Key Figures having same reference currecy key. If it is happening for all the key figures containing reference characteristic,
    GO to CUNI,
    Find the specific currency and set the decimal place to 99, this would enable this KF to store and display the value with 99 decimal precision.
    NOTE: You can always override to less number of decimals in BEx, but you can not override more number of decimals.
    So, say currently you have 2 set in CUNI, you can not display it with 3 decimals. But if have set as 99,  you can display it with any decimal places less or equal to 99.
    - Danny

  • Decimal places default

    Hi
    Is there any way of setting a default number of decimal places for a new column added on a deski report, so that any new column added on any report will always take this default number of decimal places?
    Thanks

    Louise,
    Within the designer module you can set the default format for any of the objects within the universe.
    In the report that than will be the default format used. If you add a new column to the report the new column gets the same format as the column where you started from. So if you are in a column where the format is 3 decimal places and you insert a new column to the left or right that new column format will also have 3 decimal places.
    Regards,
    Harry

Maybe you are looking for

  • Auto posting of bank clearing account in FF67

    Hi, I am trying to complete the manual bank statement however during posting of differenty transaction type it does not post to desired bank clearing account. Where does this bank clearing account set-up for automatic determination when a certain hou

  • Looking up JMS administered objects in a rich client

    We have JMQ running as a broker. Using 'jmqjmsadm.sh' we added a Topic and a TopicConnectionFactory, using ../jmqjmsadm.sh t theLogTopic logTopic ../jmqjmsadm.sh tf providerTopicFactory TopicConnectionFactory and also set up the proxy using ../jmspad

  • How can I locate a specific widget?

    I want to find a widget that can tell me in what country a specific city is. I found the WORLDview widget but it only tells me the capitals of countries. If anyone knows the name of such a widget or if it exists please let me know

  • Connecting Humax FoxSat HD (Free Sat receiver) to ...

    Hi! I have a Humax FoxSat HD which I have connected to my BT home Hub 2 via an ethernet cable. Initially, the receiver connected to the internet no problem and I was able to watch BBC iPlayer. However, after switching my system off and then on again

  • Re: Can not get AX configured to wireless network/blinking amber light

    Discovered my AX wasn't connected to my AEBS when i couldn't play iTunes through it. I probably screwed up the settings trying to get it to work. I'm running Leopard and Airport Utility shows my AX with an amber light and says that it found an AX wit