Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java keybord reader

  1. Sep 8, 2008 #1
    I have recently started to try to teach myself java and i can't get the keybord reader to work.
    I'm a book thet's for java V1.3 but i'm using the newest version is that the problem? unless the book was wong then my program syntax should be fine. could anyone tell me what the syntax for the keybord reader is?
  2. jcsd
  3. Sep 9, 2008 #2
    BufferedReader in
    = new BufferedReader(new InputStreamReader(System.in));

    I believe this is what you need. Are you planning to run your program using the cmd or gui?
  4. Sep 9, 2008 #3
    cmd it's just a basic temp. converting program. I'm not used to jave I've only programmed on my ti 83+, 89T, and Nspier
  5. Sep 9, 2008 #4
    if i copy and past my program could you show me what's wrong? the book that i have is fron 2004 so i don't know if it's syntax is out of date or not.
  6. Sep 9, 2008 #5
    Sure...you could copy and paste it here. I take a look at it. See whats up.

    FYI: I'm a intermediate java and c++ programmer.
  7. Sep 12, 2008 #6
    public class converter {
    public static void main(String [] args) {
    KeyboardReader reader = new KeyboardReader();
    double f;
    double c;

    System.out.print("enter F: ");
    f =reader.readDouble();

    c = (f-32.0)*5.0/9.0;

    System.out.println("The equivalent in c is ");

  8. Sep 12, 2008 #7
    that's exactly as it was in my java book.
  9. Sep 12, 2008 #8


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You need to tell us EXACTLY what's happening -- what error messages you're seeing, etc. -- not just "I can't get it to work."

    The "KeyboardReader" is not a standard part of the Java programming language. If the KeyboardReader was provided in your book, you need to also type that into a file called "KeyboardReader.java" and compile it along with your own program.

    - Warren
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook