Author |
Message |
princess
|
Posted: Wed Feb 11, 2004 7:55 pm Post subject: input from the user |
|
|
i noe how to get numbers from the user.... but those numbers are only integers how can i make them numbers wit decimals? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Wed Feb 11, 2004 7:57 pm Post subject: (No subject) |
|
|
use double or floot type variables. |
|
|
|
|
![](images/spacer.gif) |
princess
|
Posted: Wed Feb 11, 2004 7:59 pm Post subject: (No subject) |
|
|
.... ya but how do u change the input from a string to a double?? |
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Wed Feb 11, 2004 8:01 pm Post subject: (No subject) |
|
|
Double.parseDouble or something like that, i forgot the exact cases. |
|
|
|
|
![](images/spacer.gif) |
princess
|
Posted: Wed Feb 11, 2004 8:06 pm Post subject: (No subject) |
|
|
alrite thanx i'll try it |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Wed Feb 11, 2004 9:20 pm Post subject: (No subject) |
|
|
use JOption.ShowInputDialog |
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Wed Feb 11, 2004 9:59 pm Post subject: (No subject) |
|
|
That can only input string I though, or if Im mistaken I have to change the tutorial. You still end up use Double.parseDouble. |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Thu Feb 12, 2004 7:33 pm Post subject: (No subject) |
|
|
yeah... why dont u just parse it in? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Thu Feb 12, 2004 9:37 pm Post subject: (No subject) |
|
|
It's not tested, but...
code: | import java.lang.*;
import java.io.*;
import java.util.*;
class Test
{
public static void main(String[] args)
{
BufferedReader keyboard = new BufferedRead(
new InputStreamReader(System.in));
// read in a line
String userInput = keyboard.readLine();
// store the double input
doube parsedUserInput = Double.parseDouble(userInput);
// do something with the double
}
} |
|
|
|
|
|
![](images/spacer.gif) |
|