You are on page 1of 2

ASSIGNMENT- LAB 10

Q. Write a program to develop an applet that receives three


numeric values as input from the user and then displays the
largest of the three on the screen. Write a HTML page for testing
the same applet..

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Main extends Applet implements ActionListener {

TextField a,b,c,d;

public void paint(Graphics g) {


g.drawString("is the largest among the three entered
numbers",600,50);
}

public void init()


{
a=new TextField(25);
b=new TextField(25);
c=new TextField(25);
add(a);
add(b);
add(c);
Button bu=new Button("Click to display the largest
number");
add(bu);
bu.addActionListener((ActionListener) this);
d=new TextField(25);
add(d);
}

public void actionPerformed(ActionEvent e) {

String str1,str2,str3;
str1=a.getText();
str2=b.getText();
str3=c.getText();
int x=Integer.parseInt(str1);
int y=Integer.parseInt(str2);
int z=Integer.parseInt(str3);

if(x>y && x>z) {


d.setText(str1);
}

else if(y>z) {
d.setText(str2);
}

else
{
d.setText(str3);
}
}
}

You might also like