Having trouble converting a string to a double

Im having problems converting a string to a double in my jsp pages, i have pasted part of the code that is causing the problem. Just a note, i have imported the java.lang.* classes also
while ( rs.next() )
String price = rs.getString("price");
sPrice = double.parseDouble(price);
out.println("<TD>$" + decimalFormat.format(sPrice) + " </TD>");
An error occurred at line: 140 in the jsp file: /cs399/AddToShoppingCart.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\jakarta-tomcat-4.1.29\work\Standalone\localhost\_\cs399\AddToShoppingCart_jsp.java:277: class expected
          sPrice = double.parseDouble("price");
^

double is a primitive. You want java.lang.Double, with a capital "D":
sPrice = Double.parseDouble(price);MOD

Similar Messages

  • Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

    I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
    think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?

    Hi Biz
    I don't think there is a direct way of converting a complex number to a
    string, so when you convert the array to a spreadsheet string, the
    numbers would be converted to real data.
    However, you could try separating the real and imaginary parts using the
    "Numeric: Complex to Re/Im" function, and then store these - either in
    separate files or in adjacent columns/rows in the same file. Then, when
    you read in the data again, use the "Numeric: Re/Im to Complex" function
    to put the two "halves" together.
    If you actually want Excel to interpret the numbers as imaginary, then
    you'll probably want to create a string for each complex number of the
    form "Re + Im*i" (after separating the Re and Im parts), by using
    "String:Format into String" with 2 numeric inputs and the format string
    "%f+%fi".
    Reading the data back into Labview then would require splitting the
    string into the 2 pieces by using "Stringcan from String" with 2
    numeric outputs (smae precision as original numbers specified by the 2
    Default Value inputs) and the same format string "%f+%fi", and then using
    the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
    me, so if you can't follow what I am describing, send me an email and I
    can email you what I did (LV 5.1.1).
    Paul
    Biz wrote:
    > Having trouble converting array to spreadsheet string, storing the
    > file and coverting back to array with complex numbers
    >
    > I am working with a network analyzer. I have arrays made of 5 columns
    > the first consisting of an integer and the next four consisting of
    > complex numbers. I am converting the array into a spreadsheet string
    > and then saving the file using the write characters to a file VI. That
    > seems to work well as when I open the file in Excel all the data is
    > there. However when I try to reverse the process, open file and
    > convert back to array, I loose some of the data. Specifically the
    > imaginary parts of my complex numbers are all going to zero. I have
    > narrowed down the problem to be in the conversion from spreadsheet
    > string to array and vice versa. I think the problem may be with the
    > 'format' input to the VI. I do not have an adequate resource for this
    > so I am not sure what to put in to accomplish my task. Any takers?
    Research Assistant
    School of Physiotherapy, Curtin University of Technology
    Selby Street, Shenton Park, Western Australia, Australia. 6008
    email: [email protected]
    Tel. +61 8 9266 4657 Fax. +61 8 9266 3699
    "Everyone who calls on the name of the Lord will be saved." Romans 10:12
    "For all have sinned and fall short of the glory of God, and are
    justified freely by his grace through the redemption that came by Christ
    Jesus." Romans 3:23-4

  • I'm having troubles converting my raw files from Nikon D5200 (NEF) to DNG. I tried using Lightroom 4, but it didn't identify the folder containing the files. So i downloaded the latest DNG converter but that too didn't identify the files kept in the folde

    I'm having troubles converting my raw files from Nikon D5200 (NEF) to DNG. I tried using Lightroom 4, but it didn't identify the folder containing the files. So i downloaded the latest DNG converter but that too didn't identify the files kept in the folder location. So I downloaded DNG converter v7.3 for D5200. It identifies the folder and files; but it is giving me parsing error on trying to convert files. I'm running Windows Vista Home Edition SP1. Kindly advise. Thank you.

    I probably missed this detail in what you’ve posted, but do you see the thumbnails of the three cameras’ raw files in Finder if you don’t convert to DNG?
    What has happened in the past is that the Apple raw interpreter doesn’t read thumbnails of DNGs it doesn’t like, where at least one thing it didn’t used to like was embedded lens corrections for mirrorless cameras.  Are the Olympus and Panasonic mirrorless—meaning there is no optical viewfinder and everything is seen on an LCD screen or perhaps an electronic view finder?  If so the reason these are different is that the camera is doing the lens distortion corrections automatically and this information is stored in the raw files and in the DNGs but Apple doesn’t know how to use these embedded lens corrections or doesn’t know how to read the newer DNG spec that does allow for this information to be embedded in the DNG, at least.
    Apple could just extract the embedded jpg preview and ignore the other parts of the file it doesn’t understand, but it apparently doesn’t do this.
    What I’m not sure about is if the Apple raw interpreter still has this problem or if you’re on an older system without the latest updates for camera raw decoding by Apple.

  • How do you convert this String into a double?

    Hi, in this code I want to convert String arg into a double. I'm trying to do this so that I can convert some string into a double in this calculator that I'm making. Here is the code:
    public class par {
    public static void main(String[] args) {
    String str = "351";
    double arg = new double(str); // should convert the string into a double
         System.out.println(arg);
         System.out.println(str);
    I keep getting errors in line 4, if any of you could help me out here I'll be thankful, i'm kinda new to java and my search for java's equivalent of alof() (its a function in C libraries that converts char[] into a double)lead me to this.
    Tony L.

    Use the Following:
    String num = "123.2";
    double d = Double.parseDouble(num);

  • How do I convert a string to a double, a number loses the precision

    I tried converting a string to a double but that limits the precision. I need to convert a string to a double.

    If you use the Scan From String function, the default is to convert to a dbl. If you're looking at a front panel indicator, don't confuse the format and precision of the indicator with the type representation. You can set the indicator to display as many digits as you want but that doesn't change the actal number stored in memory.

  • I'm having trouble converting my RAW files to jpegs. Even though my RAW files are 90MB plus, the jpegs when converted are only around 6MB.  Am I doing something wrong?  Thanks,  A

    Dear Forum,
    I realise this isn’t necessarily your problem, buy I’m having trouble converting my RAW files to jpegs.
    Even though my RAW files are 90MB plus, the jpegs when converted are only around 6MB.
    Am I doing something wrong?
    Thanks,
    A

    HHi Barbara, thanks for replying to my post.
    No there's nothing wrong with the Jpegs, but I want to srart uploading images for sale in Alamy, but they say they must be a minimum of 17mb un compressed. Does that mean that at 6mb compressed from 90mb they'd be acceptable?
    thanks,
    alex

  • Converting a String to a Double, may I use Double constructor?

    Hello,
    I need to convert A String to a Double in my application.
    Usually I use the Double.parseDouble(String) method that works fine.
    But I have found one line in the code that use the Double class constructor: new Double(String). It has been observed that that constructor sometimes throws NullPointerException.
    My question is, are theses two methods both good practices to do the convertion? Could threre be a multi-threading problem with the Double construtor?
    I'm using JDK 1.3.1.
    Here is a sample of stack trace:
    bvsmgr: java.lang.NullPointerException
         at java.lang.FloatingDecimal.readJavaFormatString(Unknown Source)
         at java.lang.Double.valueOf(Unknown Source)
         at java.lang.Double.<init>(Unknown Source)
    Thank you for all answers,
    Florent.

    But I have found one line in the code that use the
    Double class constructor: new Double(String).
    It has been observed that that constructor sometimes
    throws NullPointerException.
    My question is, are theses two methods both good
    practices to do the convertion? Could threre be a
    multi-threading problem with the Double construtor?Both methods are the same (they both use valueOf()), and if the c'tor throws an NPE, then only because you feed it null. parseDouble would do that, too.

  • How to convert a String data to Double or Float???? Thank you

    I need to convert String data to Double or Float , please help me about it. Thank you very muh!
    String a=Integer.parseInt("1234"); convert to integer.

    I found it but do not know if it is ok
    float a= Float.valueof(String to
    convert).floatValue();
    may be it can be!!!
    Thank you !!!!How did parseInt lead you do valueOf?
    Look for something more consistent. A pattern.As I said earlier, it depends if he wants an object or a primitive.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Having troubles converting RGB to CMYK

    @Hi guys
    I having massive issues with converting my business logo form RGB to CMYK. I need to place this logo on my business card ready for printing. I created the logo in RGB format to start of with, but it keeps coming out darker and abit grayscaled
    once the conversation is set. Can anyone help me out with this issue, and if so, can you also provide the steps in how to resolve this issue for future references. Im using Adobe Photoshop CS5 for this execise. I can also provide the actual image attached below as the second image,.

    These bright pink and purple colours are obviously way out of gamut so they convert badly to CMYK. Exactly how they convert depends on what colour profile you are using
    It will probably be best to either rework the design using mixtures of cyan and magenta only or else use mixtures of Pantone colours.
    The Pantone solution will only work for offset printing but is no use for a home printer.
    Read up on colour management like Mylenium says and learn to think in terms of inks rather than screen colours.

  • Having trouble converting video to dvd

    Hi there. I am trying to convert an 8mm tape to dvd. I imported using FCP, i made my necessary edits and then converted them to a quicktime file and imported the clips to iDVD and burned my disc. the problem I am having is that when I playback the dvd anytime there is motion it gets very pixelated and looks like garbage. I am sure there is a setting that I am missing, or not converting it properly. I really need some help on this.
    here is the process by which I am exporting the edited piece to burn to DVD,
    Export: Using Quicktime conversion. My settings are: Compression H.264, Quality: best, Key Frame Rate:24, Encoding:multipass, and Dimensions 720x480(4:3)
    I am just looking for the most convenient way to transfer and edit these tapes to dvd without the glaring pixelation problems.
    thanks
    Jason

    Jason
    here is the process by which I am exporting the edited piece to burn to DVD,
    Export: Using Quicktime conversion. My settings are: Compression H.264, Quality: best, Key Frame Rate:24, Encoding:multipass, and Dimensions 720x480(4:3)
    First, you must feed iDVD with an uncompressed copy of your movie, what means, same settings that your timeline. Select Export > Quicktime Movie (not conversion!) > Same settings. Then use that file as soure in iDVD. iDVD will encode this file to MPEG2 video.
    Second, I suggest you learn to use Compressor and DVDSP. iDVD will not give you too much encoding control. With Compressor you can set the exact encoding parameters you need, including AC3 (Dolby) audio. iDVD uses AIFF audio that can cause skips when playting in stand alone players because the high bitrate.
    Hope that helps !
      Alberto

  • Converting a String to a double....why this error? how to solve?

    Hello guys
    I have a string (the string temp) that contains "4444.0"
    I need to have it in double format so I wrote:
    double fatto2 = Double.parseDouble(temp);this puts in the variable fatto2 the value "0.0"
    I tried also
    double fatto2 = Double.valueOf(temp).doubleValue();and also this expression puts "0.0" in the variable.
    I am struggling on this stupid issue :|
    I think it might depend on the string being not only formed with numbers (there's the decimal dot) but I have no idea on how to solve it
    somebody can give me a hint?!?!?
    thanks

    wow, you're right....
    I wasn't using it as I was thinking
    I filled that section with printlns and discovered that the one I was thinking to be the supposed value was a println popping up from somewhere else in the code......
    stupid errors.....all the day coding, I'd better sleep, and I'll do it now :|
    well....thanks a lot

  • Having trouble converting a pdf document to word .docx

    http://answers.acrobatusers.com/ViewQuestion.aspx?tc=1811155930102109201488816&q=211509&ac tion=watchQuestion&questionId=211509&vote=1 
    I bought Adobe ExportPDF, Annual membership to convert PDF documents into .docx but can't seem to do this now.
    My pdf is stuck on 'Retrieving current session status' when I try to convert it to .docx. Why?

    Hi Florence,
    I have accessed a document however the conversion has generated this letter head... It should read JAPSER CORNER
    and this signature...
    So... when I used to click on the Tools button, it was very simple to convert the document. It's not so simple now - still not working.
    Can you please advise me as to how to regain full operation of this Tool and Adobe product.
    Can you please check that my subscription is up to date.

  • Having trouble converting quick time to mpeg4

    i have a bunch of music videos that are in quick time format that i would like to put on my ipod, but when i try and "convert selection for ipod" it gives me a message that i cant be converted because the file does not allow converting or saving... is there some way i can work around this or am i just not going to get to watch my videos on my ipod?

    On my ibook, I just add the quicktime video to itunes, then select it and go to the edit toolbar on top (I think it is the edit toolbar, check them all) and click "convert selection for iPod". Whenever i have done this for a quicktime video the audio and video both work great and it goes onto my ipod just fine.
    Hope this Helps!

  • I'm having trouble converting a Word Form to a PDF form because the table cells are importing incorrectly. How can I fix it?

    I am converting a form from Word to PDF. The form includes several tables and the tables are converting with weird lines where the corners meet. I've tried everything. I've even retyped a portion of the form and tried importing it but it still had the weird lines. I'd rather not recreate the form in PDF because it's not short and I already have a perfectly good form to import. Any suggestions?

    What version of Word? What version of Acrobat? How exactly are you converting the file?

  • I'm having trouble converting file to excel...i just purchased this yesterday

    I keep getting the message
    'FILE FAILED TO BE CONVERTED USING ADOBE EXPORTPDF ONLINE
    PLEASE HELP.

    I have just purchased Adobe PKF Pack, I am trying to convert from PDF TO WORD.  The reason why is that I cannot adjust the margin stops and it won't change the user file name when I go to save. example I have file mamed Herman and I want to save it under Betty it will not save.
    I have paid $ 1.99 per month for a year and if I cannot convert then I don't need ADOBE PDF PACK

Maybe you are looking for