java if staatement

Posted on 2008-11-12
Last Modified: 2012-05-05
I am determine which of the two randomly generated integers is the larger of the two and display it to the scree in the last JOption statement.  

JOptionPane.showMessageDialog(null, "The larger of the two numbers " + (value) + " and " + num + " is ");

any help would greatly be appreciated.
package randomtester;
import java.util.Random;
import javax.swing.JOptionPane;
public class Main
    public static void main(String[] args)
        String input;
      Random generator = new Random();
 int num;
  num = generator.nextInt(100);
int value;
     input = JOptionPane.showInputDialog("Please enter a number of your choice");
  //  value = Double.parseDouble(input);
     value = Integer.parseInt(input);
     JOptionPane.showMessageDialog(null, "The First random number picked was " + (value));
     JOptionPane.showMessageDialog(null, "The second random number picked was " + (num));
     JOptionPane.showMessageDialog(null, "The larger of the two numbers " + (value) + " and " + num + " is ");

Question by:ca1358
    LVL 59

    Accepted Solution

    You can do an inline IF here:

    JOptionPane.showMessageDialog(null, "The larger of the two numbers " + value + " and " + num + " is " + ((value > num)?value:num));


    Author Closing Comment

    Thank you!
    LVL 59

    Expert Comment

    by:Kevin Cross
    You are welcome!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now