Skip to main content

Find maximum of two numbers without using third variable in JAVA in JAVA

CODING:
import javax.swing.JOptionPane;
class max
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "A", "Find Maximum Number", JOptionPane.PLAIN_MESSAGE);
String b=JOptionPane.showInputDialog(null, "B", "Find Maximum Number", JOptionPane.PLAIN_MESSAGE);
if(Integer.parseInt(a) > Integer.parseInt(b))
 {
  JOptionPane.showMessageDialog(null,"Max Number is : " + Integer.parseInt(a));
 }
else
 {
  JOptionPane.showMessageDialog(null,"Max Number is : " + Integer.parseInt(b));
 }
System.exit(0);
}
}

Comments