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="arithmatic" width=800 height=800>
<param name="a" value="30">
<param name="b" value="20">

</applet>
</body>
</html>
*/

public class arithmatic extends Applet 
{
 int n1, n2, add, sub, mul, div;
public void init()
{
 n1 = Integer.parseInt(getParameter("a"));
 n2 = Integer.parseInt(getParameter("b")); 

 }
 
 public void paint(Graphics g)
 {
 g.drawString("First Number : "+n1,100,40);
 g.drawString("Second Number : "+n2,100,60);
 g.drawString("Addition is : "+(n1+n2),100,80);
 g.drawString("Subtraction is : "+(n1-n2),100,100); 
 g.drawString("Multiplication is : "+(n1*n2),100,120); 
 g.drawString("Divide is : "+(n1/n2),100,140); 
 } 
 }
OUTPUT
First Number      : 30
Second Number     : 20
Addition is       : 50
Subtraction is    : 10
Multiplication is : 600
Divide is         : 1

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA