Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 input from the user
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
princess




PostPosted: 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
Sponsor
sponsor
Paul




PostPosted: Wed Feb 11, 2004 7:57 pm   Post subject: (No subject)

use double or floot type variables.
princess




PostPosted: 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




PostPosted: Wed Feb 11, 2004 8:01 pm   Post subject: (No subject)

Double.parseDouble or something like that, i forgot the exact cases.
princess




PostPosted: Wed Feb 11, 2004 8:06 pm   Post subject: (No subject)

alrite thanx i'll try it
Homer_simpson




PostPosted: Wed Feb 11, 2004 9:20 pm   Post subject: (No subject)

use JOption.ShowInputDialog
Paul




PostPosted: 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




PostPosted: Thu Feb 12, 2004 7:33 pm   Post subject: (No subject)

yeah... why dont u just parse it in?
wtd




PostPosted: 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
   }
}
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: