Find the greatest of 3 nos
import javax.swing.JOptionPane;
public class Greatest_of_3_nos
{
public static void main(String[] args)
{
int a,b,c;
a=Integer.parseInt( JOptionPane.showInputDialog("Enter an value of a"));
b=Integer.parseInt(JOptionPane.showInputDialog( "Enter an value of b"));
c=Integer.parseInt(JOptionPane.showInputDialog( "Enter an value of c"));
if (a > b && a > c)
{
System.out.print(a+" is the greatest");
}
else if (c > b && a < c)
{
System.out.print(c+" is the greatest");
}
else
{
System.out.print(b+" is the greatest");
}
}
}
No comments:
Post a Comment