Sunday, August 4, 2013

89. APRIORI ALGORITHM IN JAVA

import java.io.*;
import java.util.*;

public class Apriori {

    public static void main(String[] args) {
        AprioriCalculation ap = new AprioriCalculation();
        ap.aprioriProcess();
    }
}
class AprioriCalculation
{

88. ADDRESS TRANSLATION OF 80386 IN PROTECTED MODE IN JAVA

import java.util.*;
class addrxlation
{
                public static void main(String args[])
                {
                                Scanner read = new Scanner(System.in);
                String GDT[][]={{"0000000000000000","00000000000000000000000000001111"},{"0000000000000001","00000000000000000000000011111111"},
{"0000000000000010","00000000000000000000111111111111"}};
                String PD[][]={{"00000000000000000000000000000000","00000000000000000001000000000000"},{"00000000000000000000000000000001","00000000000000000010000000000000"},
{"00000000000000000000000000000001","00000000000000000011000000000000"}};

87. BRANCH PREDICTION LOGIC IN JAVA

import java.io.*;
import java.util.*;
class bpl
{/*Status taken
3:Strongly Taken
2:Weakly Taken
1:Weakly Not Taken
0:Strongly Not Taken*/
                static String btb[][];
public static void main(String args[])throws IOException
{

86. FLOATING POINT ADDER IN JAVA

import java.io.*;
import java.util.*;
class FloatingPointAdder
{          int exp;
            Scanner s=new Scanner(System.in);
            float n1,n2;
            String temp1="",temp2="";
            int exp1,exp2;
            String tmp1="",tmp2="";
            char cry='0';    
            char s1='0',s2='0';
            String e1,e2;
            String m1="", m2="";
            int cmn_expo;
            void input()
            {

Tuesday, July 23, 2013

85. CAESER CIPHER IN JAVA

import java.io.*;
class Crypto
{
static int i,k,j,m,n;
static String pt="",ct="";
public static void main(String arg[])throws IOException
{
j=Integer.parseInt(arg[0]);
InputStreamReader isr= new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);

Friday, November 9, 2012

84. ERROR DETECTION USING CHECKSUM


//CHECKSUM
import java.util.*;

public class Checksum 
{
static int check[]=new int[4];
static int code[]=new int[12];
public static void exor(int a[], int n)
{
int i,j=0;
for(i=0;i<4;i++)
{
if((a[i]==1 && a[i+4]==1)||(a[i]==0 && a[i+4]==0))
{
check[i]=0;
}
else
{
check[i]=1;
}     
}

Wednesday, October 24, 2012

83. STOP & WAIT PROTOCOL USING SOCKETS IN JAVA


//SENDER PROGRAM

import java.io.*;
import java.net.*;
public class Sender{
Socket sender;
ObjectOutputStream out;
ObjectInputStream in;
String packet,ack,str, msg;
int n,i=0,sequence=0;
Sender(){}
public void run(){
 try{
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Waiting for Connection....");
 sender = new Socket("localhost",2004);
sequence=0;

82. JAVA PROGRAM FOR SLIDING WINDOW PROTOCOL


//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)
{

81. TCP/UDP CLIENT SERVER PROGRAM IN JAVA


//CLEINT PROGRAM

import java.io.*;
import java.net.*;
import java.lang.*;
class client
{
public static void main(String a[])throws IOException
{
Socket s=new Socket("LocalHost",8000);
DataInputStream in=new DataInputStream(s.getInputStream());
DataInputStream inn=new DataInputStream(System.in);
PrintStream dos=new PrintStream(s.getOutputStream());
while(true)
{
String str=in.readLine();
System.out.println("msg received:"+str);
if(str.equals("end"))
{

80. JAVA PROGRAM FOR HAMMING CODE


//HAMMING CODE

import java.util.*;
import java.lang.*;
class Hamming
{
            public static void main(String args[])
            {
                        int i=0,j,d=0,sum=0;
                        int a[]=new int[7];
                        int b[]=new int[11];
                        int c[]=new int[11];
                        int p[]=new int[4];
                        Scanner sr=new Scanner(System.in);
                        System.out.println("Enter the data code:");
                        for(i=0;i<7;i++)
                        {
                                    a[i]=sr.nextInt();
                        }