You are on page 1of 54

JAVA LAB PROGRAMS

PART A
1. Write a program to find factorial of the list of numbers reading from
command line argument.
factorial.java
//program to find factorial of list of numbers reading from command lime
argument
import java.io.*;
public class factorial
{
public static void main(String args[])
{
int n,x,i,j;
long f;
x=args.length;
for(i=0;i<x;i++)
{
n=Integer.parseInt(args[i]);
if(n<0)
System.out.println(n+ "\t is a Negative
number");
else if(n==0)
System.out.println("factorial of \t" +n+ "\
t is \t" +1);
else
{
f=1;
for(j=1;j<=n;j++)
f=f*j;
System.out.println("factorial of \t" + n+
"\t is\t" +f);
}
}
}
}

Output:
2. Write a program to display all prime numbers between two limits.
prime.java
//program to display all prime number between two limits
import java.io.*;
class prime
{
public static void main(String args[]) throws IOException
{
int n,m,i,j,c;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter lower limit");
n=Integer.parseInt(in.readLine());
System.out.println("enter upper limit");
m=Integer.parseInt(in.readLine());
System.out.println("prime numbers betwwen \t" + n+ "\t and \t" + m+ "\t
are:");
for(i=n;i<=m;i++)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c=c+1;
}
if(c==2)
System.out.println(i);
}

Output:

3. Write a program to sort list of elements in ascending and descending


order.
sort.java
//program to sort list of elements in ascending and descending order
import java.io.*;
class sort
{
public static void main(String args[]) throws IOException
{
try
{
int n,i,j,t;
int a[]=new int[10];
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter total number of elements");
n=Integer.parseInt(in.readLine());
System.out.println("Enter elements one by one");
for(i=0;i<n;i++)
a[i]=Integer.parseInt(in.readLine());
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}}}

System.out.println("Ascending order");
for(i=0;i<n;i++)
System.out.println(a[i]);
System.out.println("Descending order");
for(i=n-1;i>=0;i--)
System.out.println(a[i]);
}

catch(ArrayIndexOutOfBoundsException e)
{

System.out.println("The numbers of elements must be less than or equal to


10 integers");
}

Output:

4. Write a program to implement all string operations.


strops.java

// program to implement all string operations


import java.io.*;
class strops
{
public static void main(String args[]) throws IOException
{
String m1,m2,m3;
int n,ch;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("****STRING OPERATION****");
System.out.println("1. concatenate of two strings");
System.out.println("2. compares two strings");
System.out.println("3. Length of a string");
System.out.println("4. converting upper case to lower case");
System.out.println("5 . converting lower case to upper case");
System.out.println(" enter your choice");
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1:
System.out.println("enter two strings");
m1=in.readLine();
m2=in.readLine();
m3=m1.concat(m2);
System.out.println("concatenation of \t" + m1 + "\t and \t" + m2 + "\t is \t"
+m3);
break;
case 2:
System.out.println("enter two strings");
m1=in.readLine();
m2=in.readLine();
n=m1.compareTo(m2);
if(n==0)
System.out.println(m1 + "\t and \t " + m2 + "\t are \t" + "equal");
else if(n>0)
System.out.println(m1 + "\t is greater than \t" + m2);
else
System.out.println(m1 + "\t is less than \t" + m2);
break;
case 3:
System.out.println("enter string");
m1=in.readLine();
n=m1.length();
System.out.println("length of \t" + m1 +"\t is \t" +n);
break;
case 4:
System.out.println("enter string in upper case");
m1=in.readLine();
m2=m1.toLowerCase();
System.out.println(m1 + "\t converted to lower case \t" +m2);
break;
case 5:
System.out.println("enter string in lower case");
m1=in.readLine();
m2=m1.toUpperCase();
System.out.println(m1 + "\t converted to upper case \t" +m2);
break;
default:
System.out.println("invalid choice");
}
}
}

Output:

5. Write a program to find area of geometrical figures using method.


Area.java
// program to find area of geometrical figures using methods
import java.io.*;
class geometrical
{
public int square(int side)
{
return(side*side);
}
public int rectangle(int l, int b)
{
return(l*b);
}
public double circle(double r)
{
return(3.14*r*r);
}
public double triangle(double b,double h)
{
return(0.5*b*h);
}
}
class Area
{
public static void main(String args[])
{
double s,r,c,t;
geometrical ob=new geometrical();
s=ob.square(5);
r=ob.rectangle(5,10);
c=ob.circle(5.5);
t=ob.triangle(5.5,3.5);
System.out.println("Area of the square: \t" +s);
System.out.println("Area of the rectangle:\t" +r);
System.out.println("Area of the circle : \t" +c);
System.out.println("Area of the traiangle :\t" +t);
}
}
Output:

6. Write a program to implement constructor overloading by passing


different number of parameters of different types.
Exconstructor.java
import java.io.*;
class constructor
{
String name,regno;
int mark1,mark2,mark3,total;
double avg;
constructor()
{
name="";
regno="";
mark1=0;
mark2=0;
mark3=0;
total=0;
avg=0;
}
constructor(String na, String re, int m1, int m2, int m3)
{
name=na;
regno=re;
mark1=m1;
mark2=m2;
mark3=m3;
System.out.println("Student Name ="+name);
System.out.println("Register number="+regno);
System.out.println("mark1="+mark1);
System.out.println("mark2="+mark2);
System.out.println("mark3="+mark3);
}
constructor(constructor ob)
{
total=ob.mark1+ob.mark2+ob.mark3;
avg=(double)total/3;
System.out.println("Total="+total);
System.out.println("Average="+avg);
}
}
class Exconstructor
{
public static void main(String args[]) throws IOException
{
String name,regno;
int mark1,mark2,mark3;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter Student name");
name=in.readLine();
System.out.println("Enter Register Number");
regno=in.readLine();
System.out.println("Enter three subject marks");
mark1=Integer.parseInt(in.readLine());
mark2=Integer.parseInt(in.readLine());
mark3=Integer.parseInt(in.readLine());
constructor ob=new constructor(name,regno,mark1,mark2,mark3);
constructor ob1=new constructor(ob);
}
}
Output:
7.Write a program to create student report using applet, read, the input
using text boxes and displaying the output using buttons.
StudentReport.java

// program to create student report using applet, read, the input


using text boxes and displaying the output using buttons
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class StudentReport extends Applet implements ActionListener
{
Label lblregno,lblname,lblcourse,lblsem,lblsub1,lblsub2,lblsub3;
TextField txtregno,txtname,txtcourse,txtsem,txtsub1,txtsub2,txtsub3;
Button cmdreport;
String
regno="",name="",course="",sem="",sub1="",sub2="",sub3="",total="
",average="";
int tot;
float avg;
public void init()
{
lblregno=new Label("Register Number:");
lblname=new Label("Student Name:");
lblcourse=new Label("Course:");
lblsem=new Label("Semester:");
lblsub1=new Label("Subject 1:");
lblsub2=new Label("Subject 2:");
lblsub3=new Label("Subject 3:");
txtregno=new TextField(20);
txtname=new TextField(20);
txtcourse=new TextField(20);
txtsem=new TextField(20);
txtsub1=new TextField(3);
txtsub2=new TextField(3);
txtsub3=new TextField(3);
cmdreport=new Button("View Report");
add(lblregno);
add(txtregno);
add(lblname);
add(txtname);
add(lblcourse);
add(txtcourse);
add(lblsem);
add(txtsem);
add(lblsub1);
add(txtsub1);
add(lblsub2);
add(txtsub2);
add(lblsub3);
add(txtsub3);
add(cmdreport);
cmdreport.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==cmdreport)
{
regno=txtregno.getText();
name=txtname.getText();
course=txtcourse.getText();
sem=txtsem.getText();
sub1=txtsub1.getText();
sub2=txtsub2.getText();
sub3=txtsub3.getText();
tot=Integer.parseInt(sub1)+Integer.parseInt(sub2)+Integer.parseInt(su
b3);
avg=(float)tot/3;
regno="Register Number:"+regno;
name="Name:"+name;
course="Course:"+course;
sem="Semester:"+sem;
sub1="Subject 1:"+sub1;
sub2="Subject 2:"+sub2;
sub3="Subject 3:"+sub3;
total="total:"+String.valueOf(tot);
average="Average:"+String.valueOf(avg);
repaint();
}
}
public void paint(Graphics g)
{
g.drawString(regno,20,200);
g.drawString(name,20,220);
g.drawString(course,20,240);
g.drawString(sem,20,260);
g.drawString(sub1,20,280);
g.drawString(sub2,20,300);
g.drawString(sub3,20,320);
g.drawString(total,20,340);
g.drawString(average,20,360);
}
}

StudentReport.html
<Html>
<Head>
<Title>StudentReport</Title>
<Head/>
<Body>
<Center>
<Applet code=StudentReport.class Width=400 Height=400>
</Applet>
</Center>
<Body>
</Html>

Output:
8.Write a program to calculate bonus for different departments using
method overriding.
bonus.java
//program to calculate bonus for different department using overriding
import java.io.*;
abstract class department
{
double salary,bonus,netsalary;
abstract void calbonus(double salary);
abstract void display();
}
class Accounts extends department
{
public void calbonus(double sal)
{
salary=sal;
bonus=sal*0.2;
netsalary=salary+bonus;
}
void display()
{
System.out.println("Accounts\t"+salary+"\t\t"+ bonus+"\t"+netsalary);
}
}
class Sales extends department
{
public void calbonus(double sal)
{
salary=sal;
bonus=sal*0.15;
netsalary=salary+bonus;
}
void display()
{
System.out.println("Sales\t\t"+salary+"\t\t"+bonus+"\t"+netsalary);
}
}
class Production extends department
{
public void calbonus(double sal)
{
salary=sal;
bonus=sal*0.1;
netsalary=salary+bonus;
}
void display()
{
System.out.println("Production \t"+salary+"\t\t"+bonus+"\t"+netsalary);
}
}
class bonus
{
public static void main(String args[])
{
int i;
double basic[]={15000.0,20000.0,25000.0};
department dept[]=new department[20];
dept[0]=new Accounts();
dept[1]=new Sales();
dept[2]=new Production();
for(i=0;i<basic.length;i++)
dept[i].calbonus(basic[i]);
System.out.println("Department \t Basic Salary \t Bonus \t Netsalary");
System.out.println("-----------------------------------------------------------");
for(i=0;i<basic.length;i++)
dept[i].display();
}
}
Output:

9. Write a program to implement thread, applets and graphics by


implementing animation of moving ball.
Ballmoving.java
//program to demonstrate animation of Ball moving
import java.awt.*;
import java.applet.*;
import java.io.*;
public class Ballmoving extends Applet implements Runnable
{
Thread T=null;
int pos=0;
public void start()
{
T=new Thread(this);
T.start();
}
public void run()
{
while (true)
{
for(pos=0;pos<getSize().width;pos++)
{
repaint();
try
{
T.sleep(100);
}
catch(InterruptedException e)
{
}
}
}
}
public void stop()
{
T.stop();
T=null;
}
public void paint(Graphics g)
{
g.setColor(Color.green);
g.fillOval(pos,30,80,80);
g.setColor(Color.green);
g.fillOval(pos+15,43,50,50);
g.setColor(Color.red);
g.drawString("Welcome to",pos+15,65);
g.drawString("Applet & Java",pos+25,75);
}
}

Ballmoving.html
<Html>
<Head>
<Title>bollmoving</Title>
</Head>
<Body>
<Center>
<Applet code=Ballmoving.class Width=400 Height=400>
</Applet>
</Center>
</Body>
</Html>
Output:

10. Write a program to implement Mouse events And Keyboard events.


a) Program to implement mouse events using applet
b) Program to implement Keyboard events using applet
Mouse.java
//Program for Handling Mouse evnts in Applet
import java.awt.*;
import java.applet.*;
public class Mouse extends Applet
{
String msg="";
int mx=0,my=0;
public boolean mouseDown(Event obj, int x, int y)
{
mx=x;
my=y;
msg="MouseDown";
repaint();
return true;
}
public boolean mouseUp(Event obj, int x, int y)
{
mx=x;
my=y;
msg="MouseUp";
repaint();
return true;
}
public boolean mouseMove(Event obj, int x, int y)
{
mx=x;
my=y;
msg="*";
showStatus("Drawing mouse at "+x+","+y);
repaint();
return true;
}
public boolean mouseEnter(Event obj, int x, int y)
{
mx=x;
my=y; msg="Mouse just entered";
repaint();
return true;
}
public boolean mouseExit(Event obj, int x, int y)
{
mx=x;
my=y;6tz
msg="Mouse just left";
repaint();
return true;
}
public void paint(Graphics g)
{
g.drawString(msg,mx,my);
}
}
Mouse.html
<Html>
<Head>
<Title>Mouse Events</Title>
</Head>
<Body>
<Center>
<Applet code=Mouse.class Width=400 Height=400>
</Applet>
</Center>
</Body>
</Html>

Output:

Keyboard.java
//program for Handling Keybord events
import java.awt.*;
import java.applet.*;
public class Keyboard extends Applet
{
String msg="";
public boolean keyDown(Event obj, int key)
{
msg=msg+(char)key;
repaint();
showStatus("Key Down");
return true;
}
public boolean keyUp(Event obj, int key)
{
repaint();
showStatus("Key Up");
return true;
}
public void paint(Graphics g)
{
g.drawString(msg,10,20);
}
}

Keyboard.html
<Html>
<Head>
<Title>Keyboard Envents</Title>
</Head>
<Body>
<Center>
<Applet code=Keyboard.class Width=400 Height=400>
</Applet>
</Center>
</Body>
</Html>

Output:

PART B
11. A cloth showroom has announced the following seasonal discounts on
purchase of items
Purchase Amount Discount
0-100 5.0%
101-200 5.0% - 7.5%
201-300 7.5% - 10.0%
Above 300 10.0% - 15.0%
Write program using switch and if statements to compute the net amount to
be paid by a customer.
showroom.java
//discount of purchase items
import java.io.*;
class showroom
{
public static void main(String args[]) throws IOException
{
int ch;
double amount,netamt=0,dcount=0;
InputStreamReader read=new
InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("1. For Mill cloth");
System.out.println("2. For Handloom items");
System.out.println("Enter your choice....");
ch=Integer.parseInt(in.readLine());
System.out.println("Enter the purchase amount");
amount=Integer.parseInt(in.readLine());
switch(ch)
{
case 1:
if(amount<=100)
dcount=0;
if(amount>=101 && amount<=200)
dcount=amount*5.0/100;
if(amount>=201 && amount<=300)
dcount=amount*7.5/100;
if (amount>300)
dcount=amount*10.0/100;
netamt=amount-dcount;
System.out.println("Purchase Amount="+amount);
System.out.println("Discount="+dcount);
System.out.println("Amount paid by the
customer="+netamt);
break;
case 2:
if(amount<=100)
dcount=amount*5.0/100;
if(amount>=101 && amount<=200)
dcount=amount*7.5/100;
if(amount>=201 && amount<=300)
dcount=amount*10.0/100;
if (amount>300)
dcount=amount*15.0/100;
netamt=amount-dcount;
System.out.println("Purchase Amount="+amount);
System.out.println("Discount="+dcount);
System.out.println("Amount paid by the
customer="+netamt);
break;
case 3:
System.out.println("Invalid Choice");
}
}
}

Output:

12. Program to print first N Fibonacci numbers.


fibo.java

//Print the first N fibonacci numbers


import java.io.*;
class fibo
{
public static void main(String args[]) throws IOException
{
int a=1,b=1,c,n,i;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter the N value.....");
n=Integer.parseInt(in.readLine());
System.out.println("Fibonacci Numbers are:");
System.out.println(a);
System.out.println(b);
i=3;
do
{
c=a+b;
System.out.println(c);
a=b;
b=c;
i++;
} while(i<=n); } }

Output:
13. Write a program to accept A and B matrices and produce the third matrix
C=A*B
[Matrix Multiplication or Product of two matrix].
product.java
//Product of two matrices
import java.io.*;
class product
{
public static void main(String args[]) throws IOException
{
int i,j,k,x1,x2,y1,y2;
int a[][]=new int[10][10];
int b[][]=new int[10][10];
int c[][]=new int[10][10];
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter the First matrix row and column");
x1=Integer.parseInt(in.readLine());
y1=Integer.parseInt(in.readLine());
System.out.println("Enter the Second matrix row and column");
x2=Integer.parseInt(in.readLine());
y2=Integer.parseInt(in.readLine());
System.out.println("Enter the elements of first matrix");
for(i=0;i<x1;i++)
for(j=0;j<y1;j++)
a[i][j]=Integer.parseInt(in.readLine());
System.out.println("Enter the elments of second matrix");
for(i=0;i<x2;i++)
for(j=0;j<y2;j++)
b[i][j]=Integer.parseInt(in.readLine());
for(i=0;i<x1;i++)
{
for(j=0;j<y1;j++)
{
c[i][j]=0;
for(k=0;k<x2;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
System.out.println("Product of two matrix");
for(i=0;i<x1;i++)
{
for(j=0;j<y2;j++)
{
System.out.println(c[i][j]+"\t");
}
System.out.println();
}
}
}
Output:

14. Write a program to accept N string , Sort that in ascending order


[Alphabetical order].
alphabetical.java
//program for Alphabetical order
import java.io.*;
class alphabetical
{
public static void main(String args[]) throws IOException
{
int n,i,j;
String t;
String a[]=new String[10];
InputStreamReader read=new
InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter total number of string");
n=Integer.parseInt(in.readLine());
System.out.println("Enter string one by one");
for(i=0;i<n;i++)
a[i]=in.readLine();
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i].compareTo(a[j])<0)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
System.out.println("Alphabetical order");
for(i=0;i<n;i++)
System.out.println(a[i]);
}
}

Output:
15. Program to demonstrate usage of the class and objects.
Rect.java
//program to demonstrate the usage of classes and objects
import java.io.*;
class rectangle
{
int length,width;
void getdata(int x,int y)
{
length=x;
width=y;
}
int rectarea()
{
int area;
area=length*width;
return(area);
}
}
class Rect
{
public static void main(String args[]) throws IOException
{
int area1,area2;
rectangle r1=new rectangle();
r1.length=5;
r1.width=10;
area1=r1.length*r1.width;
System.out.println("Area1="+area1);
rectangle r2=new rectang
System.out.println("Area2="+area2);
}
}
Output:

16. Program to implement the concepts of multiple inheritance.


Multiple.java
//implementing multiple inheritance
import java.io.*;
class student
{
int rollno;
void getnumber(int n)
{
rollno=n;
}
void putnumber()
{
System.out.println("Roll Number="+rollno);
}
}
class test extends student
{
float part1,part2;
void getmarks(float m1,float m2)
{
part1=m1;
part2=m2;
}
void putmarks()
{
System.out.println("Marks Obtained");
System.out.println("part1="+part1);
System.out.println("part2="+part2);
}
}
interface sports
{
float sp=5.0F;
void pw();
}
class results extends test implements sports
{
float total;
public void pw()
{
System.out.println("Sports waitage="+sp);
}
void display()
{
total=part1+part2+sp;
putnumber();
putmarks();
pw();
System.out.println("Total score="+total);
}
}
class Multiple
{
public static void main(String args[])
{
results s1=new results();
s1.getnumber(1234);
s1.getmarks(25.0F,50.0F);
s1.display();
}
}
Output:

17. Write a program to demonstrate the concepts of multithreaded


programming.
Multithread.java
//Multithreaded Programming
import java.io.*;
class A extends Thread
{
public void run()
{
int i;
for(i=1;i<=5;i++)
{
if (i==1)
yield();
System.out.println("\t From Thread A : i= "+i);
}
System.out.println("Exit from A");
}
}
class B extends Thread
{
public void run()
{
int j;
for(j=1;j<=5;j++)
{
System.out.println("\t From Thread B : j= "+j);
if(j==3)
stop();
}
System.out.println("Exit from B");
}
}
class C extends Thread
{
public void run()
{
int k;
for(k=1;k<=5;k++)
{
System.out.println("\t From Thread C : k= "+k);
if(k==1)
try
{
sleep(1000);
}
catch(Exception e)
{
}
}
System.out.println("Exit from C");
}
}
class Multithread
{
public static void main(String args[])
{
A threadA=new A();
B threadB=new B();
C threadC=new C();
System.out.println("Start thread A");
threadA.start();
System.out.println("Start thread B");
threadB.start();
System.out.println("Start thread C");
threadC.start();
System.out.println("End of main thread");
}
}
Output:

18. Write an applet program to find the sum of two integers using user input.
Userinput.java
//program to find sum of two integers using applet
import java.awt.*;
import java.applet.*;
public class Userinput extends Applet
{
TextField text1,text2;
public void init()
{
text1=new TextField(10);
text2=new TextField(10);
add(text1);
add(text2);
}
public void paint(Graphics g)
{
int x=0,y=0,z=0;
String s1,s2,s;
try
{
g.drawString("input a number in each box and press enter key",10,50);
s1=text1.getText();
x=Integer.parseInt(s1);
s2=text2.getText();
y=Integer.parseInt(s2);
}
catch(Exception e)
{
}
z=x+y;
s=String.valueOf(z);
g.drawString("The Sum is :",10,75);
g.drawString(s,100,75);
}
public boolean action(Event e,Object ob)
{
repaint();
return(true);
}
}
Userinput.html
<Html>
<Head>
<Title>User Input</Title>
</Head>
<Body>
<Center>
<Applet code=Userinput.class Width=400 Height=400>
</Applet>
</Center>
</Body>
</Html>

Output:
19. Write an applet program to draw human face.
face.java
//program for drawing a human face
import java.awt.*;
import java.applet.*;
public class face extends Applet
{
public void paint(Graphics g)
{
g.drawOval(40,40,120,150);
g.drawOval(57,75,30,20);
g.drawOval(110,75,30,20);
g.fillOval(121,81,10,10);
g.fillOval(68,81,10,10);
g.fillArc(60,125,80,40,180,180);
g.drawOval(25,92,15,30);
g.drawOval(160,92,15,30);
}
}

face.html
<Html>
<Head>
<Title>Human face</Title>
</Head>
<Body>
<Center>
<Applet code=Face.class Width=400 Height=400>
</Applet>
</Center>
</Body>
</Html>
Output:
20. Write an applet program to create a Barchart using following table
Year 2012 2013 2014 2015
Result Analysis (Max 100%) 90 95 93 100

Exbarchart.java
//program for drawing bar chart
import java.awt.*;
import java.applet.*;
public class Exbarchart extends Applet
{
int n=0;
int value[];
String label[];
public void init()
{
try
{
n=Integer.parseInt(getParameter("columns"));
label=new String[n];
value=new int[n];
label[0]=getParameter("label1");
label[1]=getParameter("label2");
label[2]=getParameter("label3");
label[3]=getParameter("label4");

value[0]=Integer.parseInt(getParameter("c1"));
value[1]=Integer.parseInt(getParameter("c2"));
value[2]=Integer.parseInt(getParameter("c3"));
value[3]=Integer.parseInt(getParameter("c4"));
}
catch(NumberFormatException e)
{
}
}
public void paint(Graphics g)
{
for(int i=0;i<n;i++)
{
g.setColor(Color.blue);
g.drawString(label[i],20,i*50+30);
g.fillRect(50,i*50+10,value[i],40);
} }}
Exbarchart.html

<Html>
<Head>
<Title>Drawing barchart</Title>
</Head>
<Body>
<Center>
<applet code=Exbarchart.class Width=400 Height=400>
<PARAM NAME="columns" VALUE= "4">
<PARAM NAME="c1" VALUE="90">
<PARAM NAME="c2" VALUE="95">
<PARAM NAME="c3" VALUE="93">
<PARAM NAME="c4" VALUE="100">
<PARAM NAME="label1" VALUE="2012">
<PARAM NAME="label2" VALUE="2013">
<PARAM NAME="label3" VALUE="2014">
<PARAM NAME="label4" VALUE="2015">
</applet>
</Center>
</Body>
</Html>
Output:

You might also like