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? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Paul

|
Posted: Wed Feb 11, 2004 7:57 pm Post subject: (No subject) |
|
|
use double or floot type variables. |
|
|
|
|
 |
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?? |
|
|
|
|
 |
Paul

|
Posted: Wed Feb 11, 2004 8:01 pm Post subject: (No subject) |
|
|
Double.parseDouble or something like that, i forgot the exact cases. |
|
|
|
|
 |
princess
|
Posted: Wed Feb 11, 2004 8:06 pm Post subject: (No subject) |
|
|
alrite thanx i'll try it |
|
|
|
|
 |
Homer_simpson

|
Posted: Wed Feb 11, 2004 9:20 pm Post subject: (No subject) |
|
|
use JOption.ShowInputDialog |
|
|
|
|
 |
Paul

|
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. |
|
|
|
|
 |
Homer_simpson

|
Posted: Thu Feb 12, 2004 7:33 pm Post subject: (No subject) |
|
|
yeah... why dont u just parse it in? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
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
}
} |
|
|
|
|
|
 |
|