Program to display table of 1 to 10 on applet

This Java example displays the table of 1 to 10 numbers on applet.


PROGRAM
import java.applet.Applet;
import java.awt.*;

public class Table1To10Applet extends Applet {

 public void paint(Graphics g) {
  
  setBackground(Color.cyan);
  setForeground(Color.red);
  Font f=new Font("Cambria",Font.BOLD,16);
  g.setFont(f);
  
  int x=20,y=20;
  for(int i=1;i<=10;i++)
  {
   for(int j=1;j<=10;j++)
   {
    int k=i*j;
    g.drawString(k+"",x,y);
    x=x+30;
   }
   x=20;
   y=y+30;
  }
 }
}

/* <applet class="" width="350" height="350">
   </applet> */

OUTPUT

C:\>javac Table1To10Applet.java
C:\>appletviewer Table1To10Applet.java



Comments

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.