Google Search

Saturday, December 25, 2010

CS2357 Object Oriented Analysis and Design Lab Anna university lab manual for all exercises

OBJECTIVE: To develop a mini-project following the 12 exercises listed below.
1. To develop a problem statement.
2. Develop an IEEE standard SRS document. Also develop risk management and
project plan (Gantt chart).
3. Identify Use Cases and develop the Use Case model.
4. Identify the business activities and develop an UML Activity diagram.
5. Identity the conceptual classes and develop a domain model with UML Class
diagram.
6. Using the identified scenarios find the interaction between objects and represent
them using UML Interaction diagrams.
7. Draw the State Chart diagram.
8. Identify the User Interface, Domain objects, and Technical services. Draw the
partial layered, logical architecture diagram with UML package diagram notation.
9. Implement the Technical services layer.
10. Implement the Domain objects layer.
11. Implement the User Interface layer.
12. Draw Component and Deployment diagrams.
18
Suggested domains for Mini-project.
1. Passport automation system.
2. Book bank
3. Exam Registration
4. Stock maintenance system.
5. Online course reservation system
6. E-ticketing
7. Software personnel management system
8. Credit card processing
9. e-book management system
10. Recruitment system
11. Foreign trading system
12. Conference Management System
13. BPO Management System

Click the below links to download the manual

Click Here To download

Click Here To download

CS1403 Case Tools Lab anna university manual for all exercises

List of Experiments:

  1. Course Registration System
  2. Quiz System
  3. Online ticket reservation system
  4. Remote computer monitoring
  5. Student marks analysing system
  6. Expert system to prescribe the medicines for the given symptoms
  7. ATM system
  8. Platform assignment system for the trains in a railway station
  9. Stock maintenance
  10. E-mail Client system.
  11.  
  12. Click Here To download  

CS1403 Case Tools Lab Anna university syllabus


Case Tools Lab Syllabus


Prepare the following documents for each experiment and develop the software using software engineering methodology.

1.                            Problem Analysis and Project Planning Thorough study of the problem – Identify project scope, Objectives, infrastructure
2.                            Software Requirement Analysis Describe the individual Phases/ modules of the project, Identify deliverables.
3.                            Data Modelling Use work products – data dictionary, use case diagrams and activity diagrams, build and test class diagrams, sequence diagrams and add interface to class diagrams.
4.                            Software Development and Debugging.
5.                            Software Testing Prepare test plan, perform validation testing, coverage analysis, memory leaks, develop test case hierarchy, Site check and site monitor.

List of Experiments:

  1. Course Registration System
  2. Quiz System
  3. Online ticket reservation system
  4. Remote computer monitoring
  5. Student marks analysing system
  6. Expert system to prescribe the medicines for the given symptoms
  7. ATM system
  8. Platform assignment system for the trains in a railway station
  9. Stock maintenance
  10. E-mail Client system.

Software Required:

Case Tools: Rational Suite, Win runner, Empirix
Languages: C/C++/JDK 1.3,JSDK, INTERNET EXPLORER, UML
Front End: VB, VC++, Developer 2000
Back End: Oracle, MS-Access, SQL





Saturday, October 30, 2010

RESIDENTIAL HOUSE WIRING USING SWITCHES, FUSE, INDICATOR, LAMP AND ENERGY METER.


AIM: To construct residential house wiring using switches, fuse,
indicator, lamp and energy meter.
MATERIALS REQUIRED:
S.NO COMPONENTS DESCRIPTION QUANTITY
1 Lamps loads 5A 3
2 Bulb holder 3
3 Fuses 3
4 One way
switches
3
5 Wires
TOOLS REQUIRED:
S.NO COMPONENTS QUANTITY
1 Plier 1
2 knife 1
3 Side cutter 1
4 Screw driver 1
PROCEDURE:
1. Collect the materials required for this experiment.
2. Draw the layout of the given circuit diagram in the
circuit board.
3. Fix the necessary materials, by using drilling machine
in the layout board.
4. The lamps are fixed on the lamp holders.
5. Connections are checked and supply is given.
6. Switches are operated to see the output of the lamp.
PRECAUTIONS:
1) The metal covering of all appliances are to be
properly earthed in order to avoid electrical shock due
to leakage or failure of insulation.
2) Every line has to be protected by a fuse of suitable
rating as per the requirement.
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
GE1X03 ENGINEERING PRACTICES LABORATORY MANUAL 15
RESULT:
Thus the single-phase wiring has been constructed, tested
and the results are tabulated.
VIVA QUESTIONS:
1. Prepare the cost estimate for above wiring execution.
2. Prepare the wiring diagram for your classroom.
3. Prepare the wiring diagram for your home.
Circuit Diagram:

Fuse rating calculations:
Refer the exercise on stair case wiring & do





Layout Diagram:




FLUORESCENT LAMP WIRING


AIM: To construct a Fluorescent tube wiring.
MATERIALS REQUIRED:
S.NO COMPONENTS QUANTITY
1 Tube light 1
2 Choke 1
3 Starter 1
4 Connecting wires
5 Screws and nuts
TOOLS REQUIRED:
S.NO COMPONENTS QUANTITY
1 Plier 1
2 knife 1
3 Side cutter 1
4 Screw driver 1
THEORY: The fluorescent tubes are available in lengths of 0.61m and
1.22m.The tubes are coated from inside with phosphorous,
which is used to convert ultra violet radiations into visible
light and to give the required colour sensation. A choke is
used to give a transient high voltage so as to initiate the
electron movement. With the switch S closed, the circuit
gets closed. The current flows through the choke and the
starter. The starter suddenly breaks thereby breaking the
circuit. Due to high inductive property of the choke, a
transient high voltage is available across the filaments.
Hence electrons are emitted and travel through the tube.
Such a continuous flow of electrons produces the sensation
of light to human eyes.
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
PROCEDURE:
1) The tube light wiring is made as per the wiring diagram.
2) Supply is given and circuit is checked.
RESULT: Thus the fluorescent tube wiring has been constructed and the
working is tested.
VIVA QUESTIONS:
1. Prepare the cost estimate for above wiring execution.
2. What is the purpose starter in tube light wiring?
3. Explain the principle of operation of a tube light.
FLUORESCENT TUBE WIRING
Circuit Diagram:

Fuse rating calculations:
Refer the exercise on stair case wiring & do

STAIRCASE WIRING


1. STAIRCASE WIRING
AIM: To setup a staircase wiring using the given lamps,
controlled by switches.
MATERIALS REQUIRED:
S.NO COMPONENTS QUANTITY
1 PVC pipes
2 Junction boxes 1
3 bulb holder 1
4 PVC plates 1
5 Drilling machine 1
6 Wires
7 Two-way switch 2
TOOLS REQUIRED:
S.NO COMPONENTS QUANTITY
1 Neon tester 1
2 cutting pliers 1
3 Screwdriver 1
THEORY: In this wiring a single lamp is controlled from two places.
For this purpose two numbers of two-way switches are
used.
PROCEDURE:
1) Collect the materials required for this experiment.
2) Draw the layout of the given circuit diagram in the circuit
board.
3) Fix the necessary materials, by using drilling machine in
the layout board.
4) One end of the lamp holder is connected to neutral point
and another point is connected at the center of the two-way
switch B.
5) The center of the switch A is connected to the phase line.
6) The connection of the other two ends of two-way switch is
connected as follows. The point 1 of switch A is connected
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
GE1X03 ENGINEERING PRACTICES LABORATORY MANUAL 10
to point 1 of switch B and point 2 of A is connected to 2 of
B.
7) The given lamp is fixed on the lamp holders.
8) Controlling the switches, the circuit is checked and results
are tabulated.
RESULT: Thus the staircase wiring has been constructed, tested and the
results are tabulated.
VIVA QUESTIONS:
1. Prepare the cost estimate for above wiring execution.
2. Prepare the wiring diagram for controlling a traffic signal the road
crossing at the entrance of the college.
STAIRCASE WIRING
Circuit Diagram:

Fuse rating calculations:
Power drawn by the circuit =40 watts Voltage of circuit =230volts P=VI cos Ø
Assuming cos Ø = 1 Current in the circuit = power/ voltage = 40W/ 230V = 0.174A
Fuse rating of the circuit = rounding off the current to the nearest 5 =5A
( Normally fuses are available in the ratings of 5A, 10A and etc.)
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
Layout Diagram:

STUDY OF ACCESSORIES, TOOLS USED IN WIRING & SAFETY PRECAUTIONS


AIM:
To study the various types of accessories and tools used in house wiring.

To study safety precautions for electrical engineering practice

ACCESSORIES
Switch, Lamp Holder, Lamp holder adopter, Ceiling roses.

REQUIRED
 Mounting blocks, Socket outlets, Plugs, Main switch.
Distribution fuses boards.

TOOLS
 Cutting pliers, Flat nose pliers, Screwdriver, Neon tester,

REQUIRED:
Hammer, knife, Pocker, Pincer, Center punch, twist drill, Soldering rod.

ACCESSORIES:

1. Switch
A switch is used to make or break an electric circuit. Under some abnormal conditions it must retain its rigidity and keep its alignment between switchblades and contacts correct to a fraction of centimeter.
2. Lamp Holders
A lamp holder is used to hold the lamp required for lighting purposes.
3. Lamp holder adopter
It is used for tapping temporary power for small portable electric appliances from lamp holders. Such a practice is not advised.
4. Ceiling roses
It is an end point of an electrical wire, which provides a cover to the wire end. These are used to provide a tapping to the lamp holder through the flexible wire or a connection to a fluorescent tube or a ceiling fan. It consists of a circular base and a cover made of bakelite. One end of the plates is connected to supply and the other end to a flexible wire connected to appliances.
5. Mounting blocks
These are nothing but wooden round blocks. They are used in conjunction with ceiling roses, batten holder, surface switches, ceiling switches, etc.
6. Socket outlets
It is a wiring accessory to which electrical appliances are connected for power supply. These have insulated base with molded or socket base having three terminal sleeves. The two thin terminal sleeves are meant for making connection to the load circuit wires and the third terminal sleeve, larger in cross section, is used for an earth connection.
7. Plugs
These are used for tapping power from socket outlets. Two-pin plugs and
three-pin plugs are commonly available.
8. Main switch
This is used at the consumer’s premises so that he may have self-control
of the entire distribution circuit. This switch is a master control of all the wiring circuit made in the building. The different classifications are double poled and triple poled switches.
9. Distribution fuse boards
In industries or in very big buildings, where a number of circuits are to be wired, distribution fuse boards are used. They are usually iron clad and are designed with a large space for wiring and splitting the circuits. The fuse bank in the distribution board can easily be removed.
10. Fuse
A fuse is a protective device, which is connected such that the current flowing through the protected circuit also flows through the fuse. There is a resistive link inside the fuse body that heats or melts up when current flows through it. If the current is beyond the permissible limit, the resistive link burns open, which stops all current to flow in the circuit. At this condition we say that the fuse is blown.
11. Earthing
When a wire is connected from the ground to the outer metal casing of the electrical appliances, then it attain zero potential and the appliance is said
to be earthed and this process is known as earthing.
12. Purpose of earthing
Under normal condition, there is no electrical potential is available in the
outer metal casing of the electrical appliances. When some fault develops
in the appliances, then electrical potential leaked to the metal casing
causes heavy current flow due to earthing. This heavy current blows the
fuse and cutoff electrical supply to the appliances.
Thus earthing provides protection to human being and electrical
appliances.
TOOLS:
1. Cutting Pliers
They are used to cut the wires, nipping by hand and twisting the
wires and also to hold them. Long nose pliers are used to hold the
wires in small space and also to tighten and loosen small nuts.
2. Nose Pliers
Long nose pliers are used to hold the wires in small space and also
to tighten and loosen small nuts.
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
GE1X03 ENGINEERING PRACTICES LABORATORY MANUAL 7
3. Screw driver
They are used to drive and tighten screws into pointed holes in the
switches and electrical machines. They are generally insulated.
4. Hammer
Ball peen and claw hammers are commonly used in electrical work
where greater power is required in striking. It is best suited for
riveting purposes in sheet metal works.
5. Line tester
It is used to check the electric supply in the line or phase wire. It
has a small neon bulb, which indicates the presence of power
supply. It can also be used as a screw driver.
6. Knife
It is generally used for removing the insulation from the wire. The
closing type knife is always preferred.
7. Pocker
It is a long sharp tool used for making pilot holes in wood before
fixing and tightening wood screws.
8. Pincer
The pincer is used for extracting nails from the wood.
9. Center punch
When a hole is to be drilled in a material, the center punch is
always used for making the starting hole.
10. Twist drill
It is used for drilling holes into metals and woods.
11. Soldering rod
It is used for soldering wires to small joints with solder. It consists
of pointed oval Cu bit fixed to an iron rod, which is heated by an
electric element only.
SAFETY PRECAUTIONS:
1. While work on electrical installations, wear always rubber shoes
And avoid loose shirting.
2. Do not work on live circuits, if unavoidable use rubber gloves,
rubber mats etc
3. Use wooden or PVC insulated handle screwdrivers when working
on electric circuits.
4. Do not touch bare conductors
5. Replace or remove fuses only after switching OFF the circuit
switches.
6. Never extend wiring by using temporary wiring.
7. Stand or rubber mats while working or operating switch panels,
control gears etc.
8. Always use safety belts while working on poles or high rise
points.
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
9. Do not connect earthing to the water pipe lines.
10. Only skilled persons should do electric work.
11. Wear all the protective clothing and use all the necessary safety
equipment.
12. In case of any person suffered by electrical shook and if the victim
is still in contact with the supply, break the contact either by
switching off or by removing the plug or pulling the cable free.
13. Do not give an unconscious person anything to eat or drink and do
not leave an unconscious person unattended.
14. First restore the normal breathing to the victim and ensure that the
patient can breathe normally unaided. Then we can render other
first aids.
RESULT:
Thus a study on the various types of accessories ,tools used in house
wiring and safety precautions for electrical engineering practice was performed.

Friday, October 29, 2010

STUDY OF ALOHA PROTOCOL USING NS2 NETWORK JAVA PRORAM

Program:

#Create a simulator object

set ns [new Simulator]



#Tell the simulator to use dynamic routing

$ns rtproto DV

$ns macType Mac/Sat/UnslottedAloha



#Open the nam trace file

set nf [open aloha.nam w]

$ns namtrace-all $nf



#Open the output files

set f0 [open aloha.tr w]

$ns trace-all $f0



#Define a 'finish' procedure

proc finish {} {

global ns f0 nf

$ns flush-trace

#Close the trace file

close $f0

close $nf

#Call xgraph to display the results

exec nam aloha.nam &

exit 0 }


# Create six nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]



# Create duplex links between nodes with bandwidth and distance

$ns duplex-link $n0 $n4 1Mb 50ms DropTail

$ns duplex-link $n1 $n4 1Mb 50ms DropTail

$ns duplex-link $n2 $n5 1Mb 1ms DropTail

$ns duplex-link $n3 $n5 1Mb 1ms DropTail

$ns duplex-link $n4 $n5 1Mb 50ms DropTail

$ns duplex-link $n2 $n3 1Mb 50ms DropTail



# Create a duplex link between nodes 4 and 5 as queue position

$ns duplex-link-op $n4 $n5 queuePos 0.5



#Create a UDP agent and attach it to node n(0)

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0



# Create a CBR traffic source and attach it to udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0



#Create a Null agent (a traffic sink) and attach it to node n(3)

set null0 [new Agent/Null]

$ns attach-agent $n2 $null0



#Connect the traffic source with the traffic sink

$ns connect $udp0 $null0



#Schedule events for the CBR agent and the network dynamics

$ns at 0.5 "$cbr0 start"

$ns rtmodel-at 1.0 down $n5 $n2

$ns rtmodel-at 2.0 up $n5 $n2

$ns at 4.5 "$cbr0 stop"



#Call the finish procedure after 5 seconds of simulation time

$ns at 5.0 "finish"



#Run the simulation

$ns run

IMPLEMENTATION OF SLIDING WINDOW PROTOCOL NETWORK JAVA PROGRAM

SENDER PROGRAM:

import java.net.*;
import java.io.*;
import java.rmi.*;
public class slidsender
{
public static void main(String a[])throws Exception
{
ServerSocket ser=new ServerSocket(10);
Socket s=ser.accept();
DataInputStream in=new DataInputStream(System.in);
DataInputStream in1=new DataInputStream(s.getInputStream());
String sbuff[]=new String[8];
PrintStream p;
int sptr=0,sws=8,nf,ano,i;
String ch;
do
{
p=new PrintStream(s.getOutputStream());
System.out.print("Enter the no. of frames : ");
nf=Integer.parseInt(in.readLine());
p.println(nf);
if(nf<=sws-1) { System.out.println("Enter "+nf+" Messages to be send\n"); for(i=1;i<=nf;i++) { sbuff[sptr]=in.readLine(); p.println(sbuff[sptr]); sptr=++sptr%8; } sws-=nf; System.out.print("Acknowledgment received"); ano=Integer.parseInt(in1.readLine()); System.out.println(" for "+ano+" frames"); sws+=nf; } else { System.out.println("The no. of frames exceeds window size"); break; } System.out.print("\nDo you wants to send some more frames : "); ch=in.readLine(); p.println(ch); } while(ch.equals("yes")); s.close(); } } RECEIVER PROGRAM: import java.net.*; import java.io.*; class slidreceiver { public static void main(String a[])throws Exception { Socket s=new Socket(InetAddress.getLocalHost(),10); DataInputStream in=new DataInputStream(s.getInputStream()); PrintStream p=new PrintStream(s.getOutputStream()); int i=0,rptr=-1,nf,rws=8; String rbuf[]=new String[8]; String ch; System.out.println(); do { nf=Integer.parseInt(in.readLine()); if(nf<=rws-1) { for(i=1;i<=nf;i++) { rptr=++rptr%8; rbuf[rptr]=in.readLine(); System.out.println("The received Frame " +rptr+" is : "+rbuf[rptr]); } rws-=nf; System.out.println("\nAcknowledgment sent\n"); p.println(rptr+1); rws+=nf; } else break; ch=in.readLine(); } while(ch.equals("yes")); } } OUTPUT: SENDER: E:\bin>javac slidsender.java

E:\bin>java slidsender

Enter the no. of frames : 4

Enter 4 Messages to be send

hi...
This is network lab
This program deals with sliding window protocol
Bye

Acknowledgment received for 4 frames

Do you wants to send some more frames : yes

Enter the no. of frames : 3

Enter 3 Messages to be send

This protocol deals with bulk of frames
Acknowledgment is send after receiving bulk of frames
thank you

Acknowledgment received for 7 frames

Do you wants to send some more frames : no

E:\bin>
RECEIVER:


E:\bin>javac slidreceiver.java

E:\bin>java slidreceiver

The received Frame 0 is : hi...

The received Frame 1 is : This is network lab

The received Frame 2 is : This program deals with sliding window protocol

The received Frame 3 is : bye

Acknowledgment sent

The received Frame 4 is : This protocol deals with bulk of frames

The received Frame 5 is : Acknowledgment is send after receiving bulk of frames

The received Frame 6 is : thank you

Acknowledgment sent

E:\bin>

IMPLEMENTATION OF REMOTE METHOD INVOCATION NETWORK JAVA PROGRAM

SERVER PROGRAM:

import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
import java.lang.*;
public class rmiserver extends UnicastRemoteObject implements rmiinter
{
public rmiserver()throws RemoteException
{
}
public double add(double a1,double a2)throws RemoteException
{
return a1+a2;
}
public static void main(String arg[])throws Exception
{
rmiserver s=new rmiserver();
Naming.rebind("rmi://localhost:1099/test",s);
System.out.println("Registered");
}
}


CLIENT PROGRAM:

import java.rmi.*;
public class rmiclient
{

public rmiclient()throws RemoteException
{
}

public static void main(String arg[])throws Exception
{
rmiinter in=(rmiinter)Naming.lookup("rmi://localhost:1099/test");
double c=500.38;
double d=30.72;
System.out.println("The Sum is : "+in.add(c,d));
}
}


INTERFACE PROGRAM:

import java.rmi.*;
public interface rmiinter extends Remote
{
double add(double a,double b)throws RemoteException;
}



OUTPUT:

SERVER:


E:\bin>javac rmiserver.java

E:\bin>javac rmiinter.java

E:\bin>rmic rmiserver

E:\bin>start rmiregistry

E:\bin>java rmiserver

Registered

CLIENT:



E:\bin>javac rmiclient.java

E:\bin>java rmiclient

The Sum is : 531.1

E:\bin>

JAVA PROGRAM IN NETWORK

import java.net.*;
import java.io.*;
import java.util.Date;

public class Daytime
{

InetAddress Server;
int port=13;
public static void main(String[] args)
{
try
{
Daytime d=new Daytime("vitserver.vit.edu");
System.out.println(d.getTime());
}
catch(IOException ex)
{
System.err.println(ex);
}
}
public Daytime() throws UnknownHostException
{
this(InetAddress.getLocalHost());
}
public Daytime(String name) throws UnknownHostException
{
this(InetAddress.getByName(name));
}
public Daytime(InetAddress Server)
{
this.Server=Server;
}
public String getTime()
{
if(Server==null)
return(new Date()).toString();
try
{
Socket s=new Socket(Server,port);
InputStream is=s.getInputStream();
InputStreamReader isr=new InputStreamReader(is);
BufferedReader br=new BufferedReader(isr);
StringBuffer sb=new StringBuffer();
String theLine;
while((theLine=br.readLine())!=null)
{
sb.append(theLine +"\r \n");
}
return sb.toString();
}
catch(IOException ex)
{
return(new Date()).toString();
}
}
}

OUTPUT:
C:\Program Files\Java\jdk1.6.0\bin>javac Daytime.java

C:\Program Files\Java\jdk1.6.0\bin>java Daytime
11:25:43 PM 7/24/2010



import java.io.*;

import java.net.*;

import java.lang.*;

import java.lang.Thread;

public class NS_Lookup_Client extends Thread

{

public static void main ( String args[] )

{

// Check command line paramaters

if (args.length != 1)

{

System.err.println ("\nParamaters required! " + "\nPlease input any DomainName you wish to query.");

System.exit(1);

}

try

{

String userDomainName = args[0];

System.out.println ("\nProcessing......LookUp DNS Records for the domain " + userDomainName);

// Create dns01 server to query

String dns01 = "vitserver.vit.edu";

String dns02 = "vitserver.vit.edu";

InetAddress addr = InetAddress.getByName(dns02);

// Create a DatagramSocket

DatagramSocket s = new DatagramSocket(7667);

byte[] b = new byte[userDomainName.length()];

userDomainName.getBytes(0, userDomainName.length(), b, 0);

// Create a DatagramPacket

DatagramPacket p = new DatagramPacket(b, b.length, addr, 53);

// Connect to the DNS server

s.connect(addr , 53);

// Create input and output streams to socket

s.send(p) ;

s.receive(p);

System.out.println ((p.getData()) +

"\nThe above result is query by the following DNS Server: " + "\n" + p.getAddress());

// Terminate connection

s.close();

}

catch (SocketException e )

{

System.err.println ("Socket error : " + e);

}

catch (UnknownHostException e )

{

System.err.println ("Invalid host!");

}

catch (IOException e )

{

System.err.println ("I/O error : " + e);

}

}

}
OUTPUT:
C:\Program Files\Java\jdk1.6.0\bin>java NS_Lookup_Client 198.162.0.6

Processing......LookUp DNS Records for the domain 198.162.0.6
[B@9304b1
The above result is query by the following DNS Server:
vitserver.vit.edu/192.168.0.6

IMPLEMENTATION OF ECHO

SERVER PROGRAM:



import java.io.*;
import java.net.*;
import java.rmi.*;
class echos
{
public static void main(String args[])throws Exception
{
try
{
ServerSocket ss=new ServerSocket(2100);
Socket s=ss.accept();
DataInputStream in=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream
(s.getOutputStream());
BufferedReader br=new BufferedReader
(new InputStreamReader(System.in));
String msg=in.readUTF();
System.out.println("The message from client is:"+msg);
out.writeUTF(msg);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}














CLIENT PROGRAM:


import java.io.*;
import java.net.*;
import java.rmi.*;
class echoc
{
public static void main(String args[])throws Exception
{
try
{
Socket s=new Socket(InetAddress.getLocalHost(),2100);
DataInputStream in=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream
(s.getOutputStream());
BufferedReader br=new BufferedReader
(new InputStreamReader(System.in));
System.out.println("Enter the message:");
String msg1=br.readLine();
out.writeUTF(msg1);
String msg2=in.readUTF();
System.out.println("The message from client is:"+msg2);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

OUTPUT:

SERVER:

E:\bin>javac echos.java

E:\bin>java echos
The message from client is: Implementation of echo command

E:\bin>
CLIENT:

E:\bin>javac echoc.java

E:\bin>java echoc
Enter the message:
Implementation of echo command

E:\bin>

Wednesday, October 27, 2010

IMPLEMENTING LINEAR SEARCH program

/* IMPLEMENTING LINEAR SEARCH */


#include
template
class linsear
{
public:
T a[30],ele,i,flag,n,k;
void lisarr();
void search();
};


template
void linsear::lisarr()
{
cout<<"enter the size of the list:"; cin>>n;
cout<<"enter the elememts:"; for(i=0;i>a[i];
}
}


template
void linsear::search()
{
cout<<"enter the element to be searched:\n"; cin>>ele;
for(i=0;i l;
l.lisarr();
l.search();
}



DEPTH FIRST SEARCH program

/* DEPTH FIRST SEARCH */

#include
int x=1,a;
template
class depth
{
public:
T n,d[10][10],i,j,c[10];
void makenull()
{
int d;
for(d=0;d>n;
cout<<"\nEnter 0 if edge between the nodes else enter 0\n"; for(i=0;i>d[i][j];
}
}
void dfs(int b)
{
c[b]=1;
cout<>x;
}
};
main()
{
depth w;
w.getinput();
while(x==1)
{
cout<<"\nEnter the starting node of search\t"; cin>>a;
w.makenull();
cout<<"\nVisited node sequence is:\n";
w.dfs(a-1);
w.out();
}
cout<<"\nExiting Program\n";
}

BREADTH FIRST SEARCH PROGRAM

BREADTH FIRST SEARCH PROGRAM


/* BREADTH FIRST SEARCH */

#include
int x=1,a;
template
class breath
{
public:
T n,e[10][10],i,r,f,j,a,q[10],c[10];

void makenull()
{
int d;
r=-1;
f=0;
for(d=0;d>n;
cout<<"\nEnter 0 if edge between the nodes else enter 0\n"; for(i=0;i>e[i][j];
}
}

void bfs(int b)
{
if(c[b]==0)
{
cout<"< w;
w.getinput();
while(x==1)
{
cout<<"\nEnter the starting node of search\t"; cin>>a;
w.makenull();
cout<<"\nVisited node sequence is:\n"; w.bfs(a-1); cout<<"\nIf want to continue enter 1:\t"; cin>>x;
}
cout<<"\nexiting Program\n";
}

BINARY SEARCH PROGRAM

BINARY SEARCH PROGRAM



/* BINARY SEARCH */

#include
template
class binarysrch
{
public:
T a[10],x[10],ele,n,i,j;
void insert();
void sorting();
void search();
};


template
void binarysrch::insert()
{
cout<<"enter the no of elements:\n"; cin>>n;
cout<<"enter the elements:\n"; for(i=0;i>a[i];
}


template
void binarysrch::sorting()
{
int temp=0;
for(i=0;ia[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
cout<<"The sorted list:\n"; for(i=0;i
void binarysrch::search()
{
T x,y,z,mid;
x=0;
y=n-1;
int flag=1;
cout<<"Enter the element to be searched:\n"; cin>>ele;





for(mid=(x+y)/2;x<=y;mid=(x+y)/2) { if(a[mid]==ele) { flag=0; break; } else if(elea[mid])
{
x=mid+1;
}
}

if(flag==0)
{cout<<"\n Element Found in the location: "< b;
b.insert();
b.sorting();
b.search();
}





PRIM’S ALGORITHM

/* PRIM’S ALGORITHM */

#include
#define INF 1000
int allpair(int a[],int n);
class prims
{
public:
int perm[10],path[10],re_path[10];
int s,k,n,l,dis,newdis;
prims()
{
dis=0;
}
int wh[10][10];
void getdetails();
void calculate();
};



void prims::getdetails()
{
cout<<"\nEnter the no of nodes: "; cin>>n;
cout<<"\nEnter the weights: "; for(int i=0;i>wh[i][j];
if(wh[i][j]==0)
wh[i][j]=INF;
}
}
}


void prims::calculate()
{
s=0;
perm[s]=1;
cout<<"\nThe path is: \n"; while(allpair(perm,n)) { newdis=INF-1; do { for(int i=0;iwh[s][i]&&perm[i]==0)
{
newdis=wh[s][i];
k=i;
l=s;
}
s++;
while(s"< }
cout<<"\nThe minimum cost is: "< }


int allpair(int a[],int n)
{
int i;
for(i=0;i if(a[i]==0)
break;
if(i return 1;
else
return 0;
}



main()
{
cout<<"\nPRIM'S ALGORITHM TO CONSTRUCT SPANNING TREE AND TO CALCULATE
MINIMUM COST\t\n";
prims p;
p.getdetails();
p.calculate();
}

KRUSKAL’S ALGORITHM

KRUSKAL’S ALGORITHM

#include
template
class kruskal
{
public:
T n,e[10][10],t[10][10];
void makenull()
{
int i,j;
for(i=0;i<10;i++) for(j=0;j<10;j++) { e[i][j]=0; t[i][j]=0; } } void getinput() { int i,j; cout<<"Enter the total no of nodes\t"; cin>>n;
for(i=0;i>e[i][j];
}
}

void output()
{
int i,j;
cout<<"\nThe minimun spanning tree using kruskal algorithm is:\n"; for(i=0;i0)
{
cout<<"\nv"<v"<0))
{
temp=e[i][j];
r=i;
c=j;
}
}
}
row=r;
column=c;
do
{
cycle=0;
flag=0;
for(i=0;i0)&&(row!=i))
{
row=column;
column=i;
cycle--;
flag=1;
}
cycle++;
if(flag==1)
break;
}
}
while((cycle!=n)&&(column!=r));
if(column!=r)
{
t[c][r]=e[r][c];
t[r][c]=e[r][c];
e[r][c]=0;
e[c][r]=0;
count++;
}
else
{
e[r][c]=0;
e[c][r]=0;
}
}while(count w;
w.makenull();
w.getinput();
w.kru();
w.output();
}


DIJKSTRA’S ALGORITHM

DIJKSTRA’S ALGORITHM


/* DIJKSTRA’S ALGORITHM */

#include
#define INF 100
class dij
{
public:
int wt[20][20],preceed[20],visit[20],dis[20],dc,smdis,newdis;
int sc,dn,cur,i,j,k,n,path[20];
void get();
void find();
};


void dij::get()
{
cout<<"\n\tSHORTEST PATH ALGORITHM\n"; cout<<"\nEnter the no of nodes: "; cin>>n;
cout<<"\nEnter the weight for adjacency matrix: "; for(i=0;i>wt[i][j];
if(wt[i][j]==0)
wt[i][j]=INF;
}
visit[i]=0;
preceed[i]=-1;
dis[i]=100;
}
}


void dij::find()
{
int k;
cout<<"\nEnter the source vertex: "; cin>>sc;
cout<<"\nEnter the destination vertex: "; cin>>dn;
cur=sc;
dis[cur]=0;
visit[cur]=1;
while(cur!=dn)
{
smdis=100;
dc=dis[cur];
for(i=0;i0;k--)
cout< cout< }

main()
{
cout<<"\n\tDIJKSTRA'S ALGORITHM TO FIND SHORTEST PATH\n";
dij d;
d.get();
d.find();
}

polynomial ADDITION

#include

template
class linklist
{
public:
struct link
{
int data;
int exp;
link * next;
link(int a, int e)
{data=a;exp=e;next=NULL;}
}*first,*last;

linklist()
{first=last=NULL;}
void create(T,int);
void add(linklist,linklist);
void display();
};

template
void linklist::create(T c, int e)
{
struct link *node;
node=new struct link(c,e);

if(first==NULL)
first=last=node;
else
{
last->next=node;
last=node;
}
}

template
void linklist::display()
{
struct link *current=first;
if(current==NULL)
cout<<"\nThe list is empty\n"; else { while(current!=NULL) { if(current->data < 0) cout<<""; else cout<<" + "; cout<data;
if(current->exp!=0)
cout<<"x^"<exp<<" "; else if(current->exp=0)
cout<data;
current=current->next;
}cout<<"\n\n"; } } template
void linklist::add(linklist l1, linklist l2)
{
link *x,*y;
T c;
x=l1.first;
y=l2.first;
while((x!=NULL)&&(y!=NULL))
{
if(x->exp==y->exp)
{
c=x->data+y->data;
create(c,x->exp);
x=x->next;
y=y->next;
}
else if(x->exp > y->exp)
{
create(x->data,x->exp);
x=x->next;
}
else if(y->exp > x->exp)
{
create(y->data, y->exp);
y=y->next;
}
}
if(x!=NULL)
{
while(x!=NULL)
{
create(x->data, x->exp);
x=x->next;
}
}
if(y!=NULL)
{
while(y!=NULL)
{
create(y->data, y->exp);
y=y->next;
}
}

}

int main()
{
linklistl1,l2,l3;
int i=0,size,c,e;
cout<<"\n\tImplementation of Polynomial Addition \n"; cout<<"\t=======================================\n"; cout<<"\nEnter the no. of terms of first polynomial : "; cin>>size;
for(i=0;i>c;
cout<<"\nEnter the exponent : "; cin>>e;
l1.create(c,e);
}
cout<<"\nThe first polynomial is :\n"; l1.display(); size=0; cout<<"\nEnter the no. of terms of second polynomial : "; cin>>size;
for(i=0;i>c;
cout<<"\nEnter the exponent : "; cin>>e;
l2.create(c,e);
}
cout<<"\nThe second polynomial is :\n";
l2.display();

l3.add(l1,l2);
cout<<"\nThe sum of two polynomial is :\n";
l3.display();
}

LINK LIST IMPLEMENTATION

LINK LIST IMPLEMENTATION

/* LINK LIST IMPLEMENTATION */

#include
template
class linklist
{
public:
int count;
struct link
{
int data;
struct link *next;
}*first,*last;

linklist()
{first=last=NULL;count=0;}
void create();
void insert();
void dlete();
int IsEmpty();
void search();
void sort();
void display();
};


template
int linklist::IsEmpty()
{
if(first==NULL)
return 1;
else
return 0;
}


template
void linklist::create()
{
struct link *node;
T val;
cout<<"\nEnter the element to be created : "; cin>>val;
node=new struct link;
node->data=val;
node->next=NULL;
if(first==NULL)
first=last=node;
else
{
last->next=node;
last=node;
}
count++;
}






template
void linklist::insert()
{
struct link *node,*current,*previous;
T val;
int p=0,pos;

current=previous=first;
cout<<"\nEnter the value to be inserted : "; cin>>val;
node=new struct link;
node->data=val;
lp1:
cout<<"\nEnter the position u want to insert(1 - "<>pos;
if((pos>count+1)||(pos<1)) {cout<<"\nwrong position...Enter new position..\n";goto lp1;} else { if(pos==1) { if(first==NULL) first=last=node; else { node->next=first;
first=node;
}
}
else if(pos==count+1)
{
if(last==NULL)
first=last=node;
else
{
last->next=node;
last=node;
}
}
else
{
while(current!=NULL)
{
p++;
if(pos==p)
break;
previous=current;
current=current->next;
}
node->next=current;
previous->next=node;
}
}
count++;
}







template
void linklist::dlete()
{
struct link *prev, *current;
T val;
if(!IsEmpty())
{
cout<<"\nEnter the value to be deleted : "; cin>>val;
prev=current=first;
while(current!=NULL)
{
if(current->data==val)
break;
else
{
prev=current;
current=current->next;
}
}
if(current==NULL)
cout<<"data not found\n"; else if((current==first)&&(current==last)) first=last=NULL; else if(current==first) first=first->next;
else if(current==last)
{prev->next=NULL;last=prev;}
else
prev->next=current->next;
count--;
}
else
cout<<"\nList is empty"; } template
void linklist::sort()
{
struct link *i,*j;
T temp;
if(IsEmpty())
cout<<"\nList is Empty\n"; else { for(i=first;i!=NULL;i=i->next)
for(j=i->next;j!=NULL;j=j->next)
if((i->data)>(j->data))
{
temp=i->data;
i->data=j->data;
j->data=temp;
}
}
cout<<"\nThe sorted values : "; display(); } template
void linklist::search()
{
struct link *current=first;
T val;
cout<<"\nEnter the value to be searched : "; cin>>val;
if(IsEmpty())
cout<<"\nList is Empty\n"; else { while(current!=NULL) { if(current->data==val)
break;
current=current->next;
}
if(current==NULL)
cout<<"\nData not found in the list"; else cout<<"\n"<
void linklist::display()
{
struct link *current;
current=first;
if(IsEmpty())
cout<<"\nlist is empty"; else { cout<<"\nList is :\n"; while(current!=NULL) { cout<<"\t"<data<next;
}
}
}


int main()
{
linklist lst;
int data,ch;
do
{
cout<<"\n\t\tMENU\n"; cout<<"\t1.CREATE"; cout<<"\t2.DELETE"; cout<<"\t3.INSERT"; cout<<"\t4.SORT\n"; cout<<"\t5.SEARCH"; cout<<"\t6.ISEMPTY"; cout<<"\t7.DISPLAY"; cout<<"\t8.EXIT"; cout<<"\n\t Enter ur choice: "; cin>>ch;
switch(ch)
{
case 1: lst.create();break;
case 2: lst.dlete();break;
case 3: lst.insert();break;
case 4: lst.sort();break;
case 5: lst.search();break;
case 6: if(lst.IsEmpty())
cout<<"\nList is empty";
else
cout<<"\nList is not empty";
break;
case 7: lst.display();break;
case 8: exit(0);
}
}while(ch<8);
}