Вы находитесь на странице: 1из 37

PRACTICAL RECORD NOTE BOOK

ANNA UNIVERSITY

DEPARTMENT OF INFORMATION TECHNOLOGY

LCR COLLEGE OF ENGINEERING & TECHNOLOGY

KANCHIPADI, THIRUTHANI TALUK


THIRUVALLUR DIST – 631 204.
PRACTICAL RECORD NOTE BOOK
ANNA UNIVERSITY

LCR COLLEGE OF ENGINEERING &


TECHNOLOGY

NAME……………………………….. COURSE:

REG.NO……………………………… SEMESTER:

This is certified to be the bonafide record of work done by


the student in the Software Components Lab(IT1403) of LCR
College of Engineering and Technology in the department of
Information Technology during the year Nov-2008

Head Of the Department Staff-In-Charge

Submitted for the practical examination held on………………………..

Internal Examiner External Examiner


INDEX

PAGE
Exp.No DATE PROGRAM SIGNATURE
NO
Addition Using Java
1

Finding Greatest Number Using


2
Java
Date And Time Application
3
Using Visual Basics
Calculator Application Using
4
Component In Visual Basics
Component Implementation In
5
Visual Basics
Arithmetic Operation Using
6
RMI
Text And Image Display Using
7
RMI
Simple Hello Program Using
8
CORBA in Java
Arithmetic Implementation
9
Using CORBA In Java
Services In CORBA
10
Stock Market
sum.java

import java.io.*;
public class sum
{
public static void main(String args[])throws IOException
{
int i,sum=0;
for(i=0;i<30;i++)
sum=sum+i;
System.out.println("The Sum is :"+sum);
}
}
OUTPUT:
Great.java

import java.io.*;
class great
{
public static void main(String args[])throws IOException
{
int a,b,c;
String s;
DataInputStream dis=new DataInputStream(System.in);
System.out.print("Enter A:");
s=dis.readLine();
a=Integer.parseInt(s);
System.out.print("Enter B:");
s=dis.readLine();
b=Integer.parseInt(s);
if(a>b)
System.out.println("Greatest is:"+a);
else
System.out.println("Greatest is:"+b);
}
}
OUTPUT
Application using com
SOURCE CODE :

1. CREATION

Public Function timer()


MsgBox Now
End Function

2. IMPLEMENTATION

Private Sub Command1_Click()


Dim A As New Time.Class1
A.Timer
End Sub
FORM DESIGN :

OUTPUT :

:
Active x control using calculator
SOURCE CODE :

Dim flag As String


Dim sum As Integer
Dim cur As Integer
Dim cl As Integer

Private Sub Command1_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 1
cur = Val(Text1.Text)
cl = 0
End Sub

Private Sub Command10_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 0
cur = Val(Text1.Text)
cl = 0
End Sub

Private Sub Command11_Click()


Text1.Text = Text1.Text + "."
End Sub

Private Sub Command12_Click()


arifn
flag = "+"
Text1.Text = sum
cl = 1
End Sub

Private Sub Command13_Click()


arifn
flag = "*"
Text1.Text = sum
cl = 1
End Sub

Private Sub Command14_Click()


arifn
flag = "-"
Text1.Text = sum
cl = 1
End Sub

Private Sub Command15_Click()


arifn
flag = "/"
Text1.Text = sum
cl = 1
End Sub

Private Sub Command17_Click()


arifn
flag = "="
Text1.Text = sum
End Sub

Private Sub Command18_Click()


Text1.Text = ""
sum = 0
cl = 0
flag = "+"
cur = 0
End Sub

Private Sub Command2_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 2
cl = 0
cur = Val(Text1.Text)
End Sub
Private Sub Command3_Click()
If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 3
cl = 0
cur = Val(Text1.Text)
End Sub

Private Sub Command4_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 4
cl = 0
cur = Val(Text1.Text)
End Sub

Private Sub Command5_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 5
cl = 0
cur = Val(Text1.Text)
End Sub

Private Sub Command6_Click()


If (cl = 1) Then
Text1.Text = ""
End If
cl = 0
Text1.Text = Text1.Text & 6
cur = Val(Text1.Text)
End Sub

Private Sub Command7_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 7
cur = Val(Text1.Text)
cl = 0
End Sub

Private Sub Command8_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 8
cur = Val(Text1.Text)
cl = 0
End Sub

Private Sub Command9_Click()


If (cl = 1) Then
Text1.Text = ""
End If
Text1.Text = Text1.Text & 9
cl = 0
cur = Val(Text1.Text)
End Sub
Private Sub Form_Load()
sum = 0
cl = 0
flag = "+"
End Sub

Private Sub arifn()


Select Case flag
Case "+"
sum = sum + cur
Case "-"
sum = sum - cur
Case "*"
sum = sum * cur
Case "/"
sum = sum / cur
End Select
End Sub
FORM DESIGN :

OUTPUT :
Active x control using progressbar
SOURCE CODE :

Private sub check1_click()


If check1.value=1 then
Timer1.enabled=true
Else
Timer1.enabled=false
End if
End sub

Private sub command1_click


ProgressBar1.value=0
Check1.value=false
End sub

Private sub text1_change()


Timer1.interval=Val(text1)
End sub

Private sub timer1_timer()


If ProgressBar1.value<80 then
ProgressBar1.value=ProgressBar1.value+1
Else
Timer1.enabled=false
End if
End sub
FORM DESIGN :

OUTPUT :
CountRMI.java

public interface countRMI extends java.rmi.Remote


{

public double sum1(double v1, double v2,char ch)throws


java.rmi.RemoteException;

CountRMIClient.java

import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;

public class countRMIClient


{

public static void main(String args[])


{
try
{
countRMI mycount=(countRMI)Naming.lookup("rmi://"+args[0]+
"/"+"countRMI");

System.out.println("RMI Arithmetic Operation");

System.out.println( "Addition Value =" + mycount.sum1(10,15,'+') );


System.out.println( "Subtraction Value =" + mycount.sum1(10,15,'-') );
System.out.println( "Multiplication Value =" + mycount.sum1(10,15,'*') );
System.out.println( "Divide Value =" + mycount.sum1(10,15,'/') );

}catch(Exception e){}
}
}
CountRMIImpl.java

import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;

public class countRMIImpl extends UnicastRemoteObject implements countRMI


{

private double sum;

public countRMIImpl(String name)throws RemoteException


{
super();
try
{
Naming.rebind(name,this);
}
catch(Exception e)
{
System.out.println("Exception");
e.printStackTrace();
}
}

public double sum1(double v1 ,double v2,char ch) throws RemoteException


{
switch(ch)
{
case '+': sum = v1 + v2; break;
case '-': sum = v1 - v2; break;
case '*': sum = v1 * v2; break;
case '/': sum = v1 / v2; break;
}

return sum;
}

}
CountRMIServer.java

import java.rmi.*;
import java.rmi.server.*;

public class countRMIServer


{
public static void main(String s[])
{

try
{
countRMIImpl mycount = new countRMIImpl("countRMI");
System.out.println("Count RMI Server Ready");

}catch(Exception e){}
}
}
OUTPUT
CountRMI.java
public interface countRMI extends java.rmi.Remote
{

public int decide(int choice)throws java.rmi.RemoteException;

CountRMIImpl.java

import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;

public class countRMIImpl extends UnicastRemoteObject implements countRMI


{
private double sum;

public countRMIImpl(String name)throws RemoteException


{
super();
try
{
Naming.rebind(name,this);
}
catch(Exception e)
{
System.out.println("Exception");
e.printStackTrace();
}
}

public int decide(int choice)throws RemoteException


{

return choice;
}

CountRMIClient.java
import java.io.*;
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code = "countRMIClient" width = 250 height = 250>
<param name = "img" value = "0.jpg">
<param name = "snd" value = "hi.au">
</applet>
*/

public class countRMIClient extends Applet implements ActionListener


{
int msg;
Button TEXT, IMAGE, SOUND;

Image img;
AudioClip snd;
String str=null,str1=null;;

public void init()


{

TEXT = new Button("TEXT");


IMAGE = new Button("IMAGE");
SOUND = new Button("SOUND");

img = getImage( getDocumentBase() , getParameter("img") );

add(TEXT);
add(IMAGE);
add(SOUND);

TEXT.addActionListener(this);
IMAGE.addActionListener(this);
SOUND.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try
{
countRMI mycount=(countRMI)Naming.lookup("rmi://"+"127.0.0.1"+
"/"+"countRMI");
str= e.getActionCommand();

if( str.equals("TEXT") ) msg = mycount.decide(1);


else if( str.equals("IMAGE") ) msg = mycount.decide(2);
else if( str.equals("SOUND") ) msg = mycount.decide(3);

if(msg==3) play( getDocumentBase(),"snd");


repaint();

}catch(Exception E){}

public void paint(Graphics g)


{
if( msg==1 ) g.drawString("JAYA",6,100);
else if( msg== 2 ) g.drawImage(img,0,0,this);

}
CountRMIServer.java

import java.rmi.*;
import java.rmi.server.*;
import java.io.*;

public class countRMIServer


{
public static void main(String s[])
{

try
{
countRMIImpl mycount=new countRMIImpl("countRMI");
System.out.println("Count RMI Server Ready");
}
catch(Exception e){}
}
}
OUTPUT
GoodDay.idl

module HelloWorld
{
interface GoodDay
{
string hello(in string name);
};
};

GoodDayImpl.java

import org.omg.CORBA.*;
import HelloWorld.*;
class GoodDayImpl extends _GoodDayStub
{
public GoodDayImpl()
{
super();
}
public String Hello(String name)
{
return "Hello!"+name;
}
}

GoodDayServer.java

import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContext.*;
import HelloWorld.*;
public class GoodDayServer
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
GoodDayImpl gdayref=new GoodDayImpl();
orb.connect(gdayref);
org.omg.CORBA.Object
objref=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objref);
NameComponent nc=new NameComponent("goodDay","");
NameComponent path[]={nc};
ncRef.rebind(path,gdayref);
System.out.println("GoodDayServer is ready");
java.lang.Object sync=new java.lang.Object();
synchronized(sync)
{
sync.wait();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

GoodDayClient.java
import java.io.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import HelloWorld.*;
public class GoodDayClient
{
public static void main(String args[])throws IOException
{
try
{
ORB orb=ORB.init(args,null);
NamingContext
ncref=NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
NameComponent path[]={new
NameComponent("goodDay","")};
GoodDay
gdayref=GoodDayHelper.narrow(ncref.resolve(path));
java.io.DataInputStream dis=new
java.io.DataInputStream(System.in);
System.out.println("Enter your name");
String name=dis.readLine();
System.out.println("Message:"+gdayref.hello(name));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

OUTPUT:
Sum.idl
module Manipulation
{
interface Sum
{
long sum(in long a,in long b);
};
};

SumImpl.java

import org.omg.CORBA.*;
import Manipulation.*;
class SumImpl extends _SumImplBase
{
public SumImpl()
{
super();
}
public int sum(int a,int b)
{
return a+b;
}
}

SumServer.java

import java.io.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContext.*;
import Manipulation.*;
public class SumServer
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
SumImpl sumref=new SumImpl();
orb.connect(sumref);
org.omg.CORBA.Object
objref=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objref);
NameComponent nc=new NameComponent("sum","");
NameComponent path[]={nc};
ncRef.rebind(path,sumref);
System.out.println("SumServer is ready");
java.lang.Object sync=new java.lang.Object();
synchronized(sync)
{
sync.wait();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

SumClient.java
import org.omg.CORBA.*;
import Manipulation.*;
import org.omg.CosNaming.*;
import java.io.*;
public class SumClient
{
public static void main(String args[]) throws IOException
{
try
{
int a,b;
ORB orb=ORB.init(args,null);
NamingContext
ncRef=NamingContextHelper.narrow(orb.resolve_initial_references("NameService"))
;
NameComponent path[]={new NameComponent("sum","")};
Sum sumref=SumHelper.narrow(ncRef.resolve(path));
java.io.DataInputStream dis=new
java.io.DataInputStream(System.in);
System.out.println("Enter the no");
a=Integer.parseInt(dis.readLine());
System.out.println("Enter second number");
b=Integer.parseInt(dis.readLine());
System.out.println("Sum"+ sumref.sum(a,b));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

OUTPUT:
StockMarket.idl
module SimpleStocks
{
interface StockMarket
{
float get_price(in string symbol);
};
};

StockMarketImpl.java

import org.omg.CORBA.*;
import SimpleStocks.*;
public class StockMarketImpl extends _StockMarketImplBase
{
public float get_price(String symbol)
{
float price=0;
for(int i=0;i<symbol.length();i++)
{
price+=(int)symbol.charAt(i);
}
price=price/5;
return price;
}
public StockMarketImpl()
{
super();
}
}

StockMarketServer.java

import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import SimpleStocks.*;
public class StockMarketServer
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
StockMarketImpl stockMarketImpl=new
StockMarketImpl();
orb.connect(stockMarketImpl);
org.omg.CORBA.Object
objRef=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objRef);
NameComponent nc=new NameComponent("NASDAQ","");
NameComponent path[]={nc};
ncRef.rebind(path,stockMarketImpl);
System.out.println("The StockMarket Server is up and ready");
Thread.currentThread().join();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

StockMarketClient.java
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import SimpleStocks.*;
public class StockMarketClient
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
NamingContext
ncRef=NamingContextHelper.narrow(orb.resolve_initial_refere
nces("NameService"));
NameComponent path[]={new
NameComponent("NASDAQ","")};
StockMarket
market=StockMarketHelper.narrow(ncRef.resolve(path));
System.out.println("Price of MY COMPANY is $"+
market.get_price("MY_COMPANY"));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

OUTPUT:

Вам также может понравиться