Question: please explain this steps it is about creating an applet with a text field for entering a number and a text field for printing the

please explain this steps it is about creating an applet with a text field for entering a number and a text field

for printing the factorial of the number

.

Marking scheme

import java.awt.*;

import java.awt.event.*;

public class FactEvent extends java.applet.Applet implements ActionListener

{

TextField t1,t2;

int fact=1,m;

Button b1,b2,b3;

String msg;

Label l1,l2;

FactEvent e;

public void init()

{

e=this;

t1=new TextField(3);

t2=new TextField(10);

b1=new Button("FIND FACTORIAL");

l1=new Label("ENTER THE NUMBER");

l2=new Label("RESULT");

add(l1);

add(t1);

add(l2);

add(t2);

add(b1);

b1.addActionListener(this);

}

public void actionPerformed(ActionEvent ae)

{

String str=t1.getText();

if(str!="")

{

int num=Integer.parseInt(str);

for(int i=num;i>0;i--)

{

fact=fact*i;

}

msg="" +fact;

t2.setText(msg);

fact=1;

}

}

}

/**/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!