Syntax for Execute this program :
Firstly then name of class and file should be and run your java file

 Syntax : Appletviewer filename.java
 Example : Appletviewer simple_applet.javaimport java.awt.*;
import java.applet.*;
import java.util.*;

/*
<html> 
 <head> 
   </head> 
 <body> 
   <applet code="factorial" width=800 height=800>       
   </applet> 
 </body> 
</html>
*/
public class factorial extends Applet implements Runnable
{
Thread t = null;
int n=0,fact=1,i,j;

 public void init()
  {
    Thread t = new Thread(this);
    t.start();
   }
   public void run()
    {
repaint();
     }
  public void paint(Graphics g)
   {
     for(i=1;i<=10;i++)
   {
     fact = fact * i;
        g.drawString("Number : "+i+" is Factorial  "+fact,20,20+(n=n+20)); 
    }
   }  
 }
OUTPUT
Number  1 is Factorial : 1
Number  2 is Factorial : 2
Number  3 is Factorial : 6
Number  4 is Factorial : 24
Number  5 is Factorial : 120
Number  6 is Factorial : 720
Number  7 is Factorial : 5040
Number  8 is Factorial : 40320
Number  9 is Factorial : 362880
Number  10 is Factorial : 3628800

{ 2 comments ... read them below or Comment }

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA