Question: Develop an applet that receives an integer in one text field,and computes its factorial value and return it in another text field, when the button named “Compute” is clicked
Question: Develop an applet that receives an integer in one text field,and computes its factorial value and return it in another text field, when the button named “Compute” is clicked
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Factorial extends Applet implements
ActionListener
{
Label l1,l2;
TextField t1,t2;
Button com;
public void init()
{
l1=new Label("Enter a no.");
add(l1);
l2=new
Label("Factorial");
add(l2);
t1=new
TextField(10);
add(t1);
t2=new
TextField(10);
add(t2);
com=new
Button("Compute");
add(com);
com.addActionListener(this);
}
public void
actionPerformed(ActionEvent e)
{
if(e.getSource()==com)
{
int
i,fact=1;
for(i=1;i<=n;i++)
{
fact=fact*i;
}
t2.setText(String.valueOf(fact));
}
}
}
/*<applet code=Factorial.class WIDTH=300 HEIGHT=200>
</applet> */
Keyword:
How to recover the classnotfoundexception in Java?
What are the top most requirements or expectations of client for develop Java web application?
Java program question paper in 2020
java applet
creating applet in java
Comments
Post a Comment