Results 1 to 16 of 16
Like Tree1Likes
  • 1 Post By gimbal2

Thread: parseDouble method problem here

  1. #1
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default parseDouble method problem here

    good day,

    our new lesson at school is in parseDouble method,
    we use textpad to evaluate the source code, (what i have installed here in my computer is textpad 7)

    i used to have this code, and it run the last time i compile it using the textpad app
    but when i turned back in my computer next morning, it shocked me with this error,

    parseDouble method problem here-pic2.jpg

    the source code looks like this,

    parseDouble method problem here-pic1.jpg

    i tried to change the parseDouble with Integer.parseInt() method and the program successfully runs, but when i returned it to parseDouble again the problem is there.

    i also tried to uninstall my textpad app then redownload it again from a website and intall it again for the hope of maybe the problem lies on the textpad ^ ^,
    however, my assumption was false and the problem is still there,..

    so, i need the help of the experts here to answer this problem for im really new to this java, any kind of answers that would help me to solve my problem,



    hopping,
    jovie

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: parseDouble method problem here

    Do you have your own class Double in your project?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    hhmmm, i did not get what do you mean by " class Double " term. the double i used in my codes is a data type,... i posted all the codes i used in performing the program, i never left any single code i missed to post here for you guys to see the whole scenario of my problem..

    #im still new to java,

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: parseDouble method problem here

    If you would post your actual code in stead of a picture of your code, it would be quite helpful. I'm not going to type all that over.

    In any case parseDouble was added in Java 1.2, so I guess you are using Java 1.1 somehow :/
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: parseDouble method problem here

    I'll rephrase: did you create your own Double class?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  6. #6
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    Quote Originally Posted by gimbal2 View Post
    If you would post your actual code in stead of a picture of your code, it would be quite helpful. I'm not going to type all that over.

    In any case parseDouble was added in Java 1.2, so I guess you are using Java 1.1 somehow :/
    oh yah sure,

    Java Code:
    import javax.swing.*;
    
    public class Rec
    {
    
      public static void main(String[] args)
        {
    	double width, length, area, perimeter;
    	String lengthStr, widthStr,outputStr;
    
    	lengthStr=JOptionPane.showInputDialog("Enter The Length: ");
    	length=Double.parseDouble(lengthStr);
    
    	widthStr=JOptionPane.showInputDialog("Enter The Width: ");
    	width=Double.parseDouble(widthStr);
    
    	area=length*width;
    	  perimeter=2*(length+width);
    	  outputStr="length: " + length + "\n" +
    		 	    "Width: " + width + "\n" +
    		 	    "Area: " + area + "\n" +
    			    "Perimeter: " + perimeter + "\n";
    	JOptionPane.showMessageDialog(null,outputStr,"Rectangle ni JOVILYN",JOptionPane.INFORMATION_MESSAGE);
    	System.exit(0);
         }
    }

  7. #7
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    Quote Originally Posted by SurfMan View Post
    I'll rephrase: did you create your own Double class?
    no...

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: parseDouble method problem here

    Compiles and runs just fine. Check the following.

    - what does the command java -version output?
    - what does the command javac -version output?
    - in the directory where you have Rec.java, is there also a file Double.java and/or Double.class?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    Quote Originally Posted by gimbal2 View Post
    Compiles and runs just fine. Check the following.

    - what does the command java -version output?
    - what does the command javac -version output?
    - in the directory where you have Rec.java, is there also a file Double.java and/or Double.class?
    yes, i did check the following you've mention, and yes in my directory i found i have a Double.class and a Double.java , i erase those two and close my textpad and reopen it, i tried to run the program (which i posted here) then, yay! thank you, ^ ^ it runs...

    however, its not clear to me what happened, whats with having Double.class in my directory mean.. can you explain to me, even just a bit of explanation pls.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: parseDouble method problem here

    What you were doing is saying "no" to poor SurfMan while you should have said "I don't know".

    And no I'm not going to invest lots of time into an explanation while you should have a perfectly good book that tells it far better than I ever can. You have more studying to do.
    SurfMan likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    Quote Originally Posted by gimbal2 View Post
    What you were doing is saying "no" to poor SurfMan while you should have said "I don't know".

    And no I'm not going to invest lots of time into an explanation while you should have a perfectly good book that tells it far better than I ever can. You have more studying to do.
    hhmm, ok, no problem, i will spend my spare time reading and getting more acquainted with new things.. thanks

  12. #12
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: parseDouble method problem here

    Problem posted: 1:40
    Solution given: 1:45
    Found the problem: 2:38

    Sometimes I wonder why I still participate in this forum. Or any forum. Teh sux.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  13. #13
    jabella is offline Member
    Join Date
    Feb 2014
    Location
    cebu
    Posts
    7
    Rep Power
    0

    Default Re: parseDouble method problem here

    for newbies, it takes time to realize.

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: parseDouble method problem here

    Quote Originally Posted by SurfMan View Post
    Problem posted: 1:40
    Solution given: 1:45
    Found the problem: 2:38

    Sometimes I wonder why I still participate in this forum. Or any forum. Teh sux.
    Its the New to Java subforum, friend SurfDude. Have mercy :)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  15. #15
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: parseDouble method problem here

    I know, I know. Too many phonecalls today... All PICNICs and PEBKACs *sigh*

    I still want to point out that you said NO to a question I asked which in the end was clearly a YES. Didn't you not understand my answer? In that case, ask for clarification instead of just saying no.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: parseDouble method problem here

    Minus 1423359 jiffies for SurfMan for forgetting to bring in his crystal ball in the forum arena.

    kindest regards,

    The Utmost Psychic Jos (Mrs)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 1
    Last Post: 10-27-2011, 07:16 AM
  2. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 11:40 AM
  3. does Double.parseDouble respect unicode
    By halyal in forum NetBeans
    Replies: 6
    Last Post: 09-06-2010, 03:18 PM
  4. Double.valueOf() vs Double.parseDouble()
    By greenbean in forum New To Java
    Replies: 10
    Last Post: 01-12-2009, 08:39 AM
  5. Replies: 29
    Last Post: 09-25-2008, 07:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •