Skip to main content

Popular posts from this blog

Applet program to find a number is prime or not using Java

import java.applet.*; import java.awt.*; import java.awt.event.*; /* <applet code="prime.class" width="500" height="600"> </applet> */ public class prime extends Applet implements ActionListener { Label lbl1; TextField txt1,txt2; Button btn1; public void init() { lbl1=new Label("Enter any Number : "); txt1=new TextField(20); txt2=new TextField(20); btn1=new Button("Check"); setLayout(null); txt2.setBounds(130,50,200,20); add(txt2); txt1.setBounds(230,100,120,20); add(txt1); lbl1.setBounds(100,100,120,20); add(lbl1); btn1.setBounds(100,120,40,20); add(btn1); btn1.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String num1=txt1.getText(); int i; int k=0; int num; String str1="Prime no."; String str2="Not Prime no."; num=Integer.parseInt(num1); for(i=1;i<=num;i++) { if(num%i==...