Rounding double for string purposes

Hello Forum,
I have small problem:
Let say I need to convert meters to feet. I have jTextFieldMeter for inputing the meters and jButtonCalculateFeet to calculate to feet. I also have jTextArea where resultS ARE displayed.
Now, calculation is perfect (button action):
double feet = Double.parseDouble(jTextFieldMeter) * 3.28083;
Here is the problem: How do I display each result in jTextArea in new line and in this order;
(jTextFieldMeter.getText() + " meters is " + feet(???) + " feet.") - but feet should be rounded after first decimal number so I get in jTextArea :
"1 meters is 3.3 feet"
And another question, how do I write in next line in jTextArea, so there are more lines (multiline).
Now I get just one same line for each new result (deletes (or overvrites?) old result)
Since I am a beginner I believe I might complicated simple task. If I am not understandable I will gladly explain more!
Thanks and sorry for my English
Kind regards, Beezgetz

Hello Prigas,
Thanxs for your reply. It helped me graet deal!
JTextArea.append("Your text with new line\n"); works a charm!
As for decimal places...
I got it just fine, but that link of yours gave me another thing to worry.
Is there a universal decimal separator? I mean . (point) or , (comma)?
If I save my doubles into xml in my room in Slovenia and send those saved doubles to some dude in Finland, how does his computer interprets decimal separator?
Am I makimg sense?
Kind regards, Beezgetz

Similar Messages

  • Linker error in c++ -- undefined reference to `vtable for String'

    While linking cpp file : wrapGetRndAmt.cpp which is below:
    wrapGetRndAmt.cpp .....
    #include <iostream.h>
    #include "archinfo.h"
    #include "syscodes.h"
    #include "currency_directory.h"
    extern MESSAGE_TYPE SetMemMarker();
    extern MESSAGE_TYPE FreeMemBlock();
    extern "C" int dm_login();
    extern "C" int dm_commit();
    extern "C" int dm_rollback();
    //extern MESSAGE_ARRAY *messageArray;
    struct tpsvcInfo *funcAry;
    /* Wrapper function to apply rounding rule (to the amount)*/
    int wrapGetRndAmt(char * ou_id, char * currency , double& amount)
    SetMemMarker();
    int rndng_rule=0;
    double rndng_val=0.0;
    double l_rtrnCode=0.0;
    double l_tmp=0.0;
    String * s_curr = new String(currency); ///This is the call of the String
    The error coming is:
    /home/gcrmdev/3.5/B/lib/h/xlstring.h:54: undefined reference to `vtable for String'
    /home/gcrmdev/3.5/B/lib/h/xlstring.h:54: undefined reference to `vtable for String'
    Header file is below:
    xlstring.h
    #ifdef SOLARIS
    11 #include "mystring.h"
    12 #else
    13 #include <string.h>
    14 #endif
    15 #include "xdr.h"
    16 #include <cppdefs.h>
    17 /* added by prabhat */
    18 #include "bglb.h"
    19 /* added by prabhat ends */
    20
    21 /*
    22 *-----------------------------------------------------------------------------
    23 * CLASS : String
    24 * PURPOSE : For performing all string operation
    25 * BASE CLASS : Object
    26 * PARENT CLASS : Object
    27 * COMMENT :
    28 * HISTORY :
    29 *-----------------------------------------------------------------------------
    30 */
    31 class String : public CppObj {
    32 int len;
    33 char *s;
    34
    35 public:
    36
    37 int operator == (const String &s1){ return strcmp(s,s1.s) ? 0 : 1;}
    38 int operator==(const Object &o)
    39 {
    40 return ( strcmp ( Type() , o.Type() ) == 0 )
    41 ? operator ==( ( const String &)o)
    42 : 0 ;
    43 }
    44 int operator != (const String &s1){ return strcmp(s,s1.s) ? 1 : 0;}
    45 int operator < (const String &s1){ return ( strcmp(s,s1.s) < 0 ) ? 1 : 0;}
    46 int operator <= (const String &s1){ return ( strcmp(s,s1.s) <= 0 ) ? 1 : 0;}
    47 int operator > (const String &s1){ return ( strcmp(s,s1.s) > 0 ) ? 1 : 0;}
    48 int operator >= (const String &s1){ return ( strcmp(s,s1.s) >= 0 ) ? 1 : 0;}
    49 operator String *() const { return new String( s ); }
    50 /* INT4 Length( INT4 & l ) const { l = len; return len; } */
    51 MESSAGE_TYPE Length( INT4 & l ) const { l = len; return XL_SUCCESS; }
    52 INT4 Length() const { return len; }
    53 /* DelhiPuneSync Changes : to take care of memAlloc fail */
    54 String( char const *s1) {
    55 if ( s1 == NULL) return;
    56 s = (char *)memAlloc((len = strlen(s1))+1);
    57 if (s != NULL)
    58 strcpy(s,s1);
    59 }
    Can someone help why this error is coming??
    Thanks is advance.
    Arabinda

    Hi,
    This is often the result of failing to include the orasqlX.lib file as input to the linker.
    I have a walkthrough of integrating Pro*C with Visual Studio here:
    http://oradim.blogspot.com/2009/05/oracle-proc-on-windows-with-express.html
    Maybe that will be of some help.
    How are you linking?
    Regards,
    Mark

  • Double.parseDouble(String) : Problem to parse large String

    Hello,
    I need to convert A String to a Double in my application without rounding of digits.
    I have used the Double.parseDouble(String) method.
    The maximum string length can be 17 including dot(.)
    So if my String is (of length 17)
    Eg.
    S= �9999999999.999999� then I am getting the double value as
    d= 9999999999.999998(compare the last digit)
    If s = �9999999999.111111� then d = 9999999999.111110
    If s = �9999999999.555555� then d = 9999999999.555555 (result that I want)
    If s = �9999999999.666666� then d = 9999999999.666666 (result that I want)
    If s = �9999999999.777777� then d = 9999999999.777777 (result that I want)
    If s = �9999999999.888888� then d = 9999999999.888887
    If s = �9999999999.999999� then d = 9999999999.999998
    If s = �9123456789.123456� then d = 9123456789.123456
    But string length up to 16 is giving me the accurate result
    So any body can explain me that why it is happening? And how can i get the accurate result.
    Thanks in advanced.

    Hi,
    Thank You for your suggestion. By which i can store
    the big double number in Data base , but at some
    point i require to parse a double value from a Double
    reference.In that case if the Decimal value length
    => 16 then it the last digit changes or rounds.
    coverting 9999999999.999999 Decimal value to double
    value. It gives me 9999999999.999998 and
    9999999999.9999999 gives me the 10000000000.0000000.
    but the Double value 999999999.999999 is ok
    and 999999999.99999999 rounds.Err, is there a follow up question in there?

  • Converting double to String

    I am looking for a way to convert double to String.
    I think that I have to use wrapper like Double class and use toString(double d), but I am not sure how to do it.
    Since toString() is static method, I do not have to have an instance of the Double class, so I was wondering what's the correct way to do it.
    I need something like this:
    String MyString = new String (String1.concat ( My_doubleNumber.Double.toString() ) );
    Any Suggestions?
    Thanks!!!

    WOW thanks a lot. These are definately better than what I thought of doing originally.
    In case I need to use the wrapper class somewhere else, I am just wondering what would be a proper use of Double and String?

  • Calendar malfunction - calendar keeps freezing and displaying text I copied for another purpose - any advice?

    My 6-month old macbook air's calendar keeps freezing up.  when I open calendar, it displays across the top of the calendar some text I copied for another purpose and which I pasted into a word document yesterday.  When this happens there's nothing I can do to escape it -- all commands result in the "thud" tone.  So I keep having to force quit calendar. 
    Any advice?

    Hi Dylan2412,
    According to your description, you'd like to pass the ComboBox.Text to the second form's TextBox.
    In Form1:
    private void button1_Click(object sender, EventArgs e)
    Form2 f2 = new Form2(this.comboBox1.Text); //pass the comboBox1.Text
    f2.Show();
    In Form2:
    public Form2(string s) //get the string;
    InitializeComponent();
    this.textBox1.Text = s;
    You could get the comBoBox refer to this sample above.
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Double.parseDouble(String) - problems when string is in scientific notation

    Hello guys,
    I'm doing some numerical calculations and I wonder whether it is possible for Double.parseDouble(String) to parse string in the scientific notation i.e. 1.0824234234E-10. Is it the notation itself causing the exception : NumberFormatException or the number is just too big/small and double can't hold it ?
    If it's just the notation how can I fix it ?
    Regards

    i'm not quite sure whether double odoes not allow it.
    perhaps consider the api Double.valueOf() and the testing code provided; reproduced below:To avoid calling this method on a invalid string and having a NumberFormatException be thrown, the regular expression below can be used to screen the input string:
            final String Digits     = "(\\p{Digit}+)";
      final String HexDigits  = "(\\p{XDigit}+)";
            // an exponent is 'e' or 'E' followed by an optionally
            // signed decimal integer.
            final String Exp        = "[eE][+-]?"+Digits;
            final String fpRegex    =
                ("[\\x00-\\x20]*"+  // Optional leading "whitespace"
                 "[+-]?(" + // Optional sign character
                 "NaN|" +           // "NaN" string
                 "Infinity|" +      // "Infinity" string
                 // A decimal floating-point string representing a finite positive
                 // number without a leading sign has at most five basic pieces:
                 // Digits . Digits ExponentPart FloatTypeSuffix
                 // Since this method allows integer-only strings as input
                 // in addition to strings of floating-point literals, the
                 // two sub-patterns below are simplifications of the grammar
                 // productions from the Java Language Specification, 2nd
                 // edition, section 3.10.2.
                 // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
                 "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
                 // . Digits ExponentPart_opt FloatTypeSuffix_opt
                 "(\\.("+Digits+")("+Exp+")?)|"+
           // Hexadecimal strings
           "((" +
            // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
            "(0[xX]" + HexDigits + "(\\.)?)|" +
            // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
            "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
            ")[pP][+-]?" + Digits + "))" +
                 "[fFdD]?))" +
                 "[\\x00-\\x20]*");// Optional trailing "whitespace"
      if (Pattern.matches(fpRegex, myString))
                Double.valueOf(myString); // Will not throw NumberFormatException
            else {
                // Perform suitable alternative action
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html

  • Tables's data scrambled (randomized) for testing purposes

    Dear Oracle People,
    I need to scramble (randomize) the date for testing purposes
    How I can do that within Oracle
    Source:
    CODE          FIRST_NAME     LAST_NAME
    1          FN_1               LN_1
    2          FN_2               LN_2
    3          FN_3               LN_3
    Target after scrambling:
    CODE          FIRST_NAME     LAST_NAME
    1          FN_2               LN_3
    2          FN_3               LN_1
    3          FN_1               LN_2

    Source table: t1
    Target table: t2 (create table t2 as select * from t1)
    Something like this would do:
    DECLARE
    rc NUMBER;
    BEGIN
    SELECT COUNT (*) INTO rc FROM t1;
    FOR i IN (SELECT last_name FROM t1)
    LOOP
    UPDATE t2
    SET last_name = i.last_name
    WHERE code = ROUND (DBMS_RANDOM.VALUE (1, rc));
    END LOOP;
    END;

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • Where to store the values for the purpose of logging

    For the purpose of logging, i would like to store few values like strings, some objects, some exceptions[ after few transactions from the end user ] in the SP server.
    which is the best approach for storing these?
    if i use  splist, the items will reach 5000 within a  week as far as my appl's usage is concerned , hence it will  cause a performance issue in future.
    so how can i store the values in the splist?
    should i use a separate  custom sql db and use ado.net to store the values when enduser peforms the tasks?
    help is appreciated

    Hi SaMolPP,
    You should try to use the existing ULS logging, following article is for 2010 but should also work in 2013 :
    http://geekswithblogs.net/venkatx5/archive/2010/12/09/how-to-use-uls-in-sharepoint-2010-for-custom-code.aspx
    No additional lists or databases needed.
    Hope this helps

  • Soundbooth CS4 - Audio Content still usable for commercial purposes?

    Dear all,
    I know that Soundbooth is no longer (officially) supported, but I wanted to double check and make sure that the CS4 Soundbooth scores and sound effects (referred to as "Audio Content" in the "CS4_LICENSE AGREEMENT FOR SOUNDBOOTH AUDIO CONTENT" located at http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/legal/licenses-terms/pdf/CS4 _LICENSE%20AGREEMENT%20FOR%20SOUNDBOOTH%20AUDIO%20CONTENT.pdf) are still usable for commercial purposes.
    In other words, I would like to make sure that I did not miss any communication from Adobe about terminating the license as mentioned (as a possibility) at article 2.7 (“Adobe may terminate this license by notifying you that your continued use of the Audio Content is prohibited”).
    Could you confirm that the “Audio Content” is still usable for commercial purposes in old and new projects?
    Thank you in advance for your help.

    ThomasThue wrote:
    ..  and the section(2M) that explained this matter back then has been deleted,...
    .. is now 2nd paragraph in §2G ...
    just as a reminder:
    this is a user2user board, I'm NO Apple representative, nor is the author of the user tipp!
    A forum chat doesn't replace professional support by a lawyer ...

  • Printing out double quote string

    Hello,
    I would like to know how can i print out the double quote string (")
    in JSP using out.print(), because a double qoute has already used
    for indicating the string. If the string that i want to print out is including double quote("), how can i print that string out.
    THX !

    out.println("\"mystring\"");
    generally: backslash "\" is used in Java to quote special characters e.g. out.println("c:\\my documents\\bla");

  • Compareto versus equals performance for strings equality

    Hi
    Just wanted to know whether compareto and equals method performance for checking whether the two strings are equal or not .
    Which one is good with respect to bytecode , speed performance.
    Im not asking for the difference, only asking which one is good to use most number of times for comparing two strings for equilaty.
    Thanks.

    Hi
    Ya they are both for different purposes. No doubt.
    t which one is faster among the two for string
    equality?
    compareto or equals.
    thanksHis point is that it doesn't matter. You shouldn't worry about optimization for small details like this. Unless you are profiling your code and find a large slowdown with that code, then don't worry about their performance. Use the one that best suits your purpose. If you want to know if they're equal, use equals(), if you want to know their order, use compareTo().

  • Using multiple apple id's for different purposes

    We are a family of 4 with numerous devices. Here's the setup we've been using to manage different aspects of our apple life!
    Each of us has an individual apple id, which we use on our individual devices for storage/backup, photo stream, facetime, calendar etc
    We have one apple id, used on all devices for all app store/itunes purchases
    We entered this id on each device with everything turned off except "find my iphone". This way we could be logged into the find my iphone app with one id and be able to see all our devices.
    This has worked really well for us as a family. Well, yesterday my kids updated their phones (one 5 and one 4s) to ios 7. I have not done it yet. It does not seem to allow for the above setup, specifically where "find my iphone" is concerned. When I enter in that specific apple id as an additional icloud account, it doesn't offer the option of find my iphone. My ios 6 device says "only your main account can use photo stream, documents & data, and backup". Their device adds "find my iphone" to this list.
    Does anyone know if this is a specific change apple made, or something that went wrong when initially setting up their updated phones.
    TIA!

    Thanks for your reply. But what I don't understand is, can I no longer have multiple icloud accounts, to be used for different purposes? Like I said, we have been using one apple id/icloud for storage etc and one for find my iphone.

  • I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    The license did not have use restrictions Licenses and terms of use | Adobe
    BUT... when your one year Education account ends, I do not think you will be able to renew at the Education rate

  • Have CS5 and CS6.  Need to reduce size of file from 6Mb to 2 Mb for contest purposes without losing original

    Have CS5 and CS6.  Need to reduce size of file from 6Mb to 2 Mb for contest purposes without losing original

    Just save the document to a new jpeg file name using a lower quality setting or re-size the image down in  size the save a high quality smaller new jpeg image.

Maybe you are looking for

  • Modify the price in good receipt without purchase order

    Hi gurus, is there any way to modify the price of a material in the good receipt without a purchase order? Kind Regards

  • Global correlation can't updated

    version is IPS7.0, asa5520-aip-ssm. Singatrue and  IME can be sucessfully updated, Global correlation can't updated, the Status of global correlation is Critical. I saw the website http://www.cisco.com/en/US/docs/security/ips/7.0/configuration/guide/

  • I can't find songs in my ipod

    ok say im trying to look for 50 cent - in da club. i goto artist but it doesn't show up.....but if i look for it under songs and i go though all my songs it will show up...how can i fix my ipod so i dun have to go through my song folder all the time?

  • Error 1327.invalid drive: C:\ when trying to install

    My computer crashed a while back and when I set up the new drive, the new root drive is "G:\"  instead of "C:\".  how can I get palm software to setup on "G"? if that is what I need to do. Post relates to: Palm m500

  • Please help -- Apps Interview questions.

    My cloning is completed successfully but my apps listener is not getting up?? What is the problem ? I am applying a patch , can I open another session in another node and run adpatch?No When database is up, listener is up. Listener.ora and tnsnames.o