Two Laptop Bag
The moose likes Beginning Java and the fly likes Trouble inputting float variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Trouble inputting float variables" Watch "Trouble inputting float variables" New topic
Author

Trouble inputting float variables

chaitanya gollapudi
Greenhorn

Joined: Mar 30, 2004
Posts: 2
Hieverbody,
Can anyone please tellme how to input floating point variables.I tried using Integer.parseInt for integers and it worked.But Double.parseDouble isnt working.How to deal with this.Thank u all.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24061
    
  13

HI,
Welcome to JavaRanch!
parseDouble() is a perfectly good routine -- can you be more specific than "isn't working?" Maybe show the code you tried, tell us what happened, and what you expected to happen instead.


[Jess in Action][AskingGoodQuestions]
chaitanya gollapudi
Greenhorn

Joined: Mar 30, 2004
Posts: 2
thanks Ernest,
i wrote a program that prompts to give cost of a thing in floating point and iused parseDouble method and i use JBuilder to compile and run my programs.While debugging its giving an error message saying
method parseDouble[java.lang.String]not found in class java.lang.Double.
But it worked fine when i used parseInteger method.Why is this so?
Thank u again in advance.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24061
    
  13

A quick check of the Javadocs shows that Double.parseDouble() was introduced in JDK 1.2 -- looks like you're working with a very old version of Java. You could instead use new Double("123.213").doubleValue() ; this ought to work in JDK 1.0 and up. Or you could upgrade to use a more recent Java 2 platform.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble inputting float variables