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 3 of 3

Thread: java program

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java program

    import java.io.Console;
    class largest{
    public static void main(String args[]){
    Console cons=System.console();
    String f1=cons.readLine("Enter First value");
    int a=Integer.parseInt(f1);
    String f2=cons.readLine("Enter second value");
    int b=Integer.parseInt(f2);
    String f3=cons.readLine("Enter third value");
    int c=Integer.parseInt(f2);
    if(a>b==a>c){
    System.out.println("largest value" +a);
    } else if(b>c==b>a){
    System.out.println("largest value" +b);}
    else if(c>a==c>b){
    System.out.println("largest value" +c);
    }
    }
    }



    not correct output


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: java program

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    Please post your code correctly and describe how the output is not correct.

    This and the others like them are interesting statements:

    if(a>b==a>c)

    What are they supposed to do?

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: java program

    Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code] to get highlighting

    Can you copy the full contents of the console when the program is executed and paste it here?

    Also code is more readable if ()s are used to enclose subexpressions: (a>b)
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Invoke a Java program with windows program
    By jackhard in forum Object Oriented Programming
    Replies: 1
    Last Post: February 21st, 2013, 07:16 AM
  2. convert java program to java ME program
    By abhishek1212 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 4th, 2013, 03:22 PM
  3. [SOLVED] Write a java program to display even numbers between 2 and 200 using netbeans java
    By Shalom in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 11th, 2012, 05:16 AM
  4. Replies: 1
    Last Post: July 8th, 2012, 10:23 AM
  5. how to run a java program..when the program using jar
    By miriyalasrihari in forum Java Theory & Questions
    Replies: 2
    Last Post: May 17th, 2012, 10:04 AM