I have this small programm written in AWT in Java.
But it's not working properly.
Please. can anyone help me out?
It's not finding out the 1st no. as greatest, evrything else is fine.
//WAP TO FIND GREATEST & SMALLEST OF NOS.
//© DHARMiL
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=Greatest height = 400 width = 500></applet>*/
public class Greatest extends Applet implements ActionListener
{
TextField t1,t2,t3,t4;
Button b1,b2;
Label l1,l2,l3,l4;
public void init ()
{
t1 = new TextField (5);
t2 = new TextField (5);
t3 = new TextField (5);
t4 = new TextField (25);
b1 = new Button ("SMALLEST");
b2 = new Button ("GREATEST");
l1 = new Label ("Enter no 1");
l2 = new Label ("Enter no 2");
l3 = new Label ("Enter no 3");
l4 = new Label ("RESULT is :-");
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
add(b2);
add(l4);
add(t4);
b2.addActionListener (this);
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == b2);
{
int a = Integer.parseInt (t1.getText());
int b = Integer.parseInt (t2.getText());
int c = Integer.parseInt (t3.getText());
{
if((a>b)&&(a>c))
{
t4.setText("no.1 is GREATER");
}
if ((b>c));
{
t4.setText ("n0.2 is GREATER");
}
else
{
t4.setText ("n0.3 is GREATER");
}
}
}
}
}


Sign In
Create Account


Back to top









