Prime Number - true , false
hey guyz , im stuck at some point of this program , ive tried to write a applet that identifies prime numbers by using boolean . however as i try to test the program there's no result showed in textfield as i click on button.
could u take a look at it n help me to solve this out ?
Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Prime1 extends Applet implements ActionListener {
private Label enterno1,prime1;
private TextField enterno2,prime2;
private Button calculate,clear;
public void init() {
enterno1=new Label(" Enter your number : ");
prime1=new Label(" Prime Form");
calculate=new Button("Calculate");
enterno2=new TextField(10);
prime2=new TextField(10);
add(enterno1);
add(enterno2);
add(prime1);
add(prime2);
add(calculate);
calculate.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if (e.getSource()==enterno1){
int n=Integer.parseInt(enterno1.getText());
int num=0;
boolean isPrime = true;
for ( int i = 1; i <= num; i++ ){
isPrime = true;
for(int y=2; y <= i/2; y++) {
if ((i%y == 0))
isPrime = false;
}
enterno2.setText(Integer.toString(i));
}
}
}
}