Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: error in this code

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default error in this code

    import java.io.*;
    public class KeyboardReading
    {
    public static void main(String args[]) throws IOException
    {
    DataInputStream dis = new DataInputStream(System.in);
    System.out.println("Enter your name: ");
    String str1 = dis.readLine();
    System.out.println("I know your name is " + str1);
    System.out.println("Enter a whole number: ");
    String str2 = dis.readLine();
    int x = Integer.parseInt(str2);
    System.out.println("Enter a double value: ");
    String str3 = dis.readLine();
    double y = Double.parseDouble(str3);

    if(x > y)
    System.out.println("First number " +x + " is greater than second number " + y);
    else
    System.out.println("First number " +x + " is less than second number " + y);

    dis.close();
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: error in this code

    When posting code, please use the highlight tags to preserve formatting.

    What's the error?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 4
    Last Post: January 24th, 2013, 11:20 AM
  2. Replies: 7
    Last Post: January 24th, 2013, 10:41 AM
  3. Error in IF-Else Code
    By jonathon6017 in forum Loops & Control Statements
    Replies: 25
    Last Post: January 18th, 2012, 03:57 AM
  4. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM
  5. Error in code
    By JCTexas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 21st, 2011, 05:53 PM