Sunday, 29 June 2014

Program For Hamming code generation,Error detection and correction:----------


#include<iostream.h>
#include<conio.h>

void main()
{
int data[7], c0, c1, c2, op,i, loc;
char a[4], b[7];
clrscr();
do
{
printf("\n 1. Hamming code generation");
printf("\n 2. Error detection and correction");\
printf("\n 3. Quit");
printf("\n 4. Enter choice :-");
scanf("%d", &op);
switch(op)
{
case 1:
printf("\n Enter a 4 bit data");
scanf("%s", a)
for(i=0; i<7;i++)
{
data[i]=0;
}
data[0]=a[0]-'0';
data[1]=a[1]-'0';
data[2]=a[2]-'0';
data[4]=a[3]-'0';
data[6]=(data[0]+data[2]+data[4])%2;
data[5]=(data[4]+data[1]+data[0])%2;
data[3]=(data[0]+data[1]+data[2])%2;
printf("\n data as encoded with hamming parity bits :\n");
printf("\n d3   d2   d1   p2   d0   p1   p0");
printf("\n");
for(i=0; i<7; i++)
{
printf("%d", data[i]);
}
break;
case 2:
printf("\nEnter a 7 bit hamming coded data :")
scanf("%s", b);
for(i=0;i<7;i++)
data[i]=b[i]-'0';
c0=(data[6]+data[0]+data[2]+data[4])%2;
c1=(data[5]+data[4]+data[1]+data[0])%2;
c2=(data[3]+data[0]+data[1]+data[2])%2;
loc=7-(4*c2+2*c1+c0);
if(loc==0)
printf("\n No Error");
else
{
printf("\nError at the location = %d", loc);
printf("\nCorrected data :");
data[loc]=(!data[loc]);
printf("\n");
for(i=0;i<7;i++)
printf("%d", data[i]);
}
break;
}
}while(op!=3);
}
Program For BOOT's Algorithm in C:--------


#include<stdio.h>
#include<conio.h>
#include<string.h>

int q1=0,n=0,count=0,Q[4],A[4],M[4],M2[4];
char b1[4],b2[4];

void input()
{
printf("\nEnter first 4-bit binary number: ");
gets(b1);
printf("\nEnter second 4-bit binary number: ");
gets(b2);
}

void initialize()
{
int a,b,i;
for(i=3;i>=0;i--)
{
a=(int)b1%10;
M[i]=a;
b1[i]/=10;
b=(int)b2%10;
Q[i]=b;
b2[i]/=10;
A[i]=0;
}
}

void add()
{
int i,a,b,c=0;
int sum[4];
for(i=3;i>=0;i--)
{
a=A[i];
b=M[i];
if((a+b+c)==0)
{
sum[i]=0;
c=0;
}
else if((a+b+c)==1)
{
sum[i]=1;
c=0;
}
else if((a+b+c)==2)
{
sum[i]=0;
c=1;
}
else if((a+b+c)==3)
{
sum[i]=1;
c=1;
}
}
for(i=0;i<4;i++)
{
A[i]=sum[i];
}
}

void twosComplement()
{
int i,b,a;
int flag=0;
for(i=0;i<n;i++)
{
if(M[i]==0) M2[i]=1;
else if(M[i]==1) M2[i]=0;
}
i=3;
while(flag==0)
{
b=M2[i];
flag=1;
if(a==1)
{
M2[i]=1;
flag=1;
break;
}
else if(a==2)
{
M2[i]=0;
i--;
}
}
}

void sub()
{
int i,a,b,c=0;
int sum[4];
twosComplement();
for(i=3;i>=0;i++)
{
a=A[i];
b=M2[i];
if((a+b+c)==0)
{
sum[i]=0;
c=0;
}
else if((a+b+c)==1)
{
sum[i]=1;
c=0;
}
else if((a+b+c)==2)
{
sum[i]=0;
c=1;
}
else if((a+b+c)==3)
{
sum[i]=1;
c=1;
}
}
for(i=0;i<n;i++) A[i]=sum[i];
}

void shift()
{
int i;
q1=Q[3];
for(i=3;i>0;i--)
{
Q[i]=Q[i-1];
}
Q[0]=A[3];
for(i=3;i>0;i--)
{
A[i]=A[i-1];
}
A[0]=A[i];
}

void display()
{
int i;
for(i=0;i<n;i++) printf("%d\t",A[i]);
for(i=0;i<n;i++) printf("%d\t%d\n",Q[i],q1);
}

void booth()
{
int i;
while(count!=0)
{
if(Q[3]==0 && q1==1)
{
add();
display();
}
else if(Q[3]==1 && q1==0)
{
sub();
display();
}
shift();
display();
printf("\nBooth's Algorithm: ");
}
printf("\nThe answer is: ");
for(i=0;i<n;i++) printf("%d",A[i]);
for(i=0;i<n;i++) printf("%d",Q[i]);
}

void main()
{
clrscr();
input();
initialize();
printf("\nA\tQ\tQ-1");
booth();
display();
printf("\n\n");

getch();
}
Program For Sum And Product For Hexadecimal Number-------------


#include<stdio.h>
#include<iostream.h>
#include<ctype.h>
#include<string.h>
#include<conio.h>

typedef struct hex_number
{
int data[15];
int n;
}hexnumber;

void leftshift(int count, hexnumber temp)
{
temp.n=temp.n+count;
for(;count>0;count--)
temp.data[temp.n+count-1]=0;
}

void read(hexnumber temp)
{
char a[10];
int i;
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(isdigit(a[i]))
{
temp.data[i]=a[i] & 0x0F;
}
else
temp.data[i]=a[i] & 0x0F + 9;
}
temp.n=i;
}

void print(hexnumber temp)
{
int i;
for(i=0;i< temp.n;i++)
{
if(temp.data[i] <= 9)
printf("%d", temp.data[i]);
else
printf("%c", (char)(temp.data[i]+55));
}
}

hexnumber add(hexnumber a, hexnumber b)
{
hexnumber c;
int i, j, k, A,B, carry=0;
i=a.n -1;
j=b.n -1;
if(a.n > b.n)
k=a.n;
else
k=b.n;
c.n =k+1;
for(;i>=0 || j>=0 ;i--, j--, k-- )
{
A=B=0;
if(i>=0)
A =a.data[i];
if(j>=0)
B =a.data[j];
c.data[k]=(carry + A +B)%16;
carry = (carry + A +B)/16;
}
c.data[k]=carry;
return(c);
}

hexnumber multiply(hexnumber x, hexnumber y)
{
hexnumber temp, z;
int n;
int count=0, product, carry=0, i, j, digit;
for(i=y.n-1;j>=0;j--)
{
digit= y.data[i];
for(j=x.n-1;j>=0;j--)
{
product =digit * x.data[j]+carry;
temp.data[j+1]=product%16;
carry=product/16;
}
temp.data[j+1]=carry;
temp.n=x.n +1;
leftshift(count, temp);
count++;
z=add(z, temp);
}
return z;
}

void main()
{
hexnumber a,b,c;
clrscr();
printf("\n Enter first hex numbers :");
read(a);
printf("\n Enter second hex numbers :");
read(b);
c= add(a,b);
printf("\n sum=");
print(c);
printf("\n Product =");
c=multiply(a,b);
print(c);
getch();
}
Program For Binary Multiplication  :-------



#include<iostream.h>
#include<string.h>

void main()
{
int num1[8], num2[8],num3[16], carry,sum, cycle, i, j;
char a[10];
printf("\nEnter first 8 bit binary number");
scanf("%s", a);
i=strlen(a) -1;
j=7;
for(;i>=0 && j>=0;i--,j--)
num1[j]=a[i]-48;
for(;j>=0;j--)
num1[j]=0;
printf("\nEnter second 8 bit binary number");
scanf("%s", a);
i=strlen(a) -1;
j=7;
for(;i>=0 && j>=0;i--,j--)
num2[j]=a[i]-48;
for(;j>=0;j--)
num2[j]=0;
for(i=0;i<16;i++)
num3[i]=0;
for(cycle=1;cycle<=8;cycle++)
{
carry=0;
if(num2[7]==1)
{
for(j=7;j>=0;j--)
{
sum=num3[j]+num1[j]+carry;
num3[j]=sum%2;
carry=sum/2;
}
}
for(i=14;i>=0;i--)
num3[i+1]=num3[i];
num3[0]=carry;
for(i=6;i>=0;i--)
num2[i+1]=num2[i];
printf("\nResult =");
for(i=0;i<16;i++)
printf("%d", num3[i]);
}
printf("\nResult =");
for(i=0;i<16;i++)
printf("%d", num3[i]);

}
Program For Checkbox In  Java-----------


import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
import java.awt.event.*;

/*<applet code="JTreedemo" width=400 height=200></applet>*/

public class JTreedemo extends JApplet
{
JTree tr;
JTextField f;

public void init()
{
Container c=getContentPane();



c.setLayout(new BorderLayout());

DefaultMutableTreeNode top=new DefaultMutableTreeNode("select");

DefaultMutableTreeNode a=new DefaultMutableTreeNode("colors");
top.add(a);

DefaultMutableTreeNode a1=new DefaultMutableTreeNode("red");
a.add(a1);
DefaultMutableTreeNode a2=new DefaultMutableTreeNode("Green");
a.add(a2);

DefaultMutableTreeNode b=new DefaultMutableTreeNode("fruits");
top.add(b);

DefaultMutableTreeNode b1=new DefaultMutableTreeNode("mango");
b.add(b1);
DefaultMutableTreeNode b2=new DefaultMutableTreeNode("apple");
b.add(b2);

DefaultMutableTreeNode c3=new DefaultMutableTreeNode("names");
top.add(c3);

DefaultMutableTreeNode c1=new DefaultMutableTreeNode("abc");
c3.add(c1);
DefaultMutableTreeNode c2=new DefaultMutableTreeNode("xyz");
c3.add(c2);
DefaultMutableTreeNode c4=new DefaultMutableTreeNode("pqr");
c3.add(c4);
DefaultMutableTreeNode c5=new DefaultMutableTreeNode("efg");
c3.add(c5);

tr=new JTree(top);

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tr,v,h);

c.add(jsp,BorderLayout.CENTER);

 f=new JTextField(20);
c.add(f,BorderLayout.SOUTH);


tr.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
doMouseClicked(me);
}
});
}

 void doMouseClicked(MouseEvent me)
{
TreePath tp=tr.getPathForLocation(me.getX(),me.getY());
if(tp!=null)
f.setText(tp.toString());
else
f.setText("");
}


}




Program For JTreedemo In Java------------


import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
import java.awt.event.*;

/*<applet code="JTreedemo" width=400 height=200></applet>*/

public class JTreedemo extends JApplet
{
JTree tr;
JTextField f;

public void init()
{
Container c=getContentPane();



c.setLayout(new BorderLayout());

DefaultMutableTreeNode top=new DefaultMutableTreeNode("select");

DefaultMutableTreeNode a=new DefaultMutableTreeNode("colors");
top.add(a);

DefaultMutableTreeNode a1=new DefaultMutableTreeNode("red");
a.add(a1);
DefaultMutableTreeNode a2=new DefaultMutableTreeNode("Green");
a.add(a2);

DefaultMutableTreeNode b=new DefaultMutableTreeNode("fruits");
top.add(b);

DefaultMutableTreeNode b1=new DefaultMutableTreeNode("mango");
b.add(b1);
DefaultMutableTreeNode b2=new DefaultMutableTreeNode("apple");
b.add(b2);

DefaultMutableTreeNode c3=new DefaultMutableTreeNode("names");
top.add(c3);

DefaultMutableTreeNode c1=new DefaultMutableTreeNode("abc");
c3.add(c1);
DefaultMutableTreeNode c2=new DefaultMutableTreeNode("xyz");
c3.add(c2);
DefaultMutableTreeNode c4=new DefaultMutableTreeNode("pqr");
c3.add(c4);
DefaultMutableTreeNode c5=new DefaultMutableTreeNode("efg");
c3.add(c5);

tr=new JTree(top);

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tr,v,h);

c.add(jsp,BorderLayout.CENTER);

 f=new JTextField(20);
c.add(f,BorderLayout.SOUTH);


tr.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
doMouseClicked(me);
}
});
}

 void doMouseClicked(MouseEvent me)
{
TreePath tp=tr.getPathForLocation(me.getX(),me.getY());
if(tp!=null)
f.setText(tp.toString());
else
f.setText("");
}


}




Program For JTabbedPane In Java-----------


import javax.swing.*;
import javax.swing.JTabbedPane;


/*<applet code="JTDemo" width=400 height=300></applet>*/

public class JTDemo extends JApplet
{
public void init()
{

JTabbedPane jtp=new JTabbedPane();
jtp.addTab("News Papers",new nwsPanel());
jtp.addTab("Magazines",new magPanel());
jtp.addTab("websites",new webPanel());


getContentPane().add(jtp);
}
}

class nwsPanel extends JPanel
{
public nwsPanel()
{
JButton b1=new JButton("Indian Express");
add(b1);
JButton b2=new JButton("Times of India");
add(b2);
JButton b3=new JButton("Sakal");
add(b3);
JButton b4=new JButton("Lokmat");
add(b4);
}
}

class magPanel extends JPanel
{
public magPanel()
{
JCheckBox jcb1=new JCheckBox("Indian Today");
add(jcb1);
JCheckBox jcb2=new JCheckBox("Review");
add(jcb2);
JCheckBox jcb3=new JCheckBox("Policy Diary");
add(jcb3);
}
}

class webPanel extends JPanel
{
public webPanel()
{
JComboBox cb1=new JComboBox();
cb1.addItem("google.com");
cb1.addItem("yahoo.com");
cb1.addItem("mns.com");
add(cb1);
}
}



Program For JTabledemo In Java:-----


import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
import java.awt.event.*;

/*<applet code="JTabledemo" width=400 height=200></applet>*/

public class JTabledemo extends JApplet
{


public void init()
{
Container c=getContentPane();



c.setLayout(new BorderLayout());

String[] colHeads={"name","phone no","city"};

Object[][] data={
{"abc","9999999","pune"},
{"xyz","8888888","mumbai"}
};

JTable tb=new JTable(data,colHeads);




int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tb,v,h);

c.add(jsp,BorderLayout.CENTER);



}


}




Program For JScrolldemo In Java;------



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/*<applet code="JScrolldemo" width=200 height=200></applet>*/

public class JScrolldemo extends JApplet
{
public void init()
{

Container c=getContentPane();

c.setLayout(new BorderLayout());

JPanel jp=new JPanel();
jp.setLayout(new GridLayout(2,2));


JRadioButton b1=new JRadioButton("Indian Express");
jp.add(b1);
JRadioButton b2=new JRadioButton("Times of India");
jp.add(b2);
JRadioButton b3=new JRadioButton("Sakal");
jp.add(b3);
JRadioButton b4=new JRadioButton("Lokmat");
jp.add(b4);

ButtonGroup bg1=new ButtonGroup();
ButtonGroup bg2=new ButtonGroup();
bg1.add(b1);
bg1.add(b2);
bg2.add(b3);
bg2.add(b4);

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(jp,v,h);

c.add(jsp,BorderLayout.CENTER);


}

}

Program For Frame In Java:----------


import javax.swing.*;
class FD extends JFrame
{
public static void main(String args[])
{
FD d=new FD();
d.setTitle("my swing frame");
d.setSize(200,250);
d.setVisible(true);
d.setLocation(20,30);
d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
java program  to  Insert Data Into MsAccess database////////////First u need to do database setting After Use //////////////////////This Program
import java.sql.*;
public class Exp11
{
    public static void main(String args[])
    {
        try
        {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             System.out.println("Drivers are properly loaded");
             System.out.println("-------------------------------------");
             Connection con= DriverManager.getConnection("jdbc:odbc:D2");
             System.out.println("Connection established");
             System.out.println("-------------------------------------");
             String url= "INSERT into Emp values(01, 'Prashant','Mumbai','Maharastra',100000,777,'MD')";
             PreparedStatement stmt = con.prepareStatement(url);
             stmt.executeUpdate();
             System.out.println("first value is inserted");
             System.out.println("-------------------------------------");
             String url1="INSERT into Emp values(02, 'Prashanti','Haidrabad','Tamilnadu',10000,775,'AS_MD')";
             PreparedStatement stmt1 = con.prepareStatement(url1);
             stmt1.executeUpdate();
             System.out.println("second value is inserted");
             System.out.println("-------------------------------------");
             String url2="INSERT into Emp values(03, 'Prashantina','Pune','Maharastra',200000,774,'CEO')";
             PreparedStatement stmt2 = con.prepareStatement(url2);
             stmt2.executeUpdate();
             System.out.println("Third value is inserted");
             System.out.println("-------------------------------------");
             String url3="INSERT into Emp values(04, 'Pradynesh','Bandup','Maharastra',20000,773,'Manager')";
             PreparedStatement stmt3 = con.prepareStatement(url3);
             stmt3.executeUpdate();
             System.out.println("Forth value is inserted");
             System.out.println("-------------------------------------");
             String url4="INSERT into Emp values(05, 'Pradynesha','Mulund','Maharastra',25000,772,'AS_Manger')";
             PreparedStatement stmt4 = con.prepareStatement(url4);
             stmt4.executeUpdate();
             System.out.println("Fifth value is inserted");
             System.out.println("-------------------------------------");
             System.out.println("All Data is succesfully inserted");
             System.out.println("-------------------------------------");
             System.out.println("Connection closed");
           con.close();
        }
       catch (SQLException e)
        {
            System.err.println("SQL error has been occure");
        }
       catch (Exception e)
        {
            System.err.println("Error connection not established");
        }
     
    }
}


OutPut:---------




Some Project List For Final Year Project---

1. inventory management system 
2. jwellery shop management 
3. Library Management System 
4. management of department store 
5. manufacturing
6. marble company 
7. media marketing system 
8. Medical Agency Mgmt 
9. Medical Store Mgmt VBNET / SQL
10. Matrimonial Management System
11. Micro Blogging Enabled Social Networking Site
12. Mobile Purchase & Sales
13. Mobile sales & service
14. Motor Driving School
15. music store automation
16. muthoot groop
17. News Paper Agency Management System
18. old age home
19. onine college admission
20. Online Admission Management System ASPNET / SQL
21. online application for the Training and Placement Dept of the college
22. Online Auctioning system like eBaycom
23. Online Examination System ASPNET / SQL
24. Online Help Desk (OHD) for the facilities in the campus
25. Online Job search portal ASPNET / SQL
26. online Library Management System (LiMS
27. Online matrimonial portal ASPNET / SQL
28. online result
29. online theatre booking system
30. Online webmart system for jewellery ASPNET / SQL
31. Patel's Super Market
32. pathology lab
33. pathpedi mgmt
34. Pharma Ceutical
35. Pizza Shop
36. police support management
37. practical online leave management system (LMS
38. practical online on‐request courses coordination system (ORS
39. practical Online Survey Tool (OST
40. practical online Tickets reservation system for Cinema halls
41. practical Time table generation system for a college
42. press management system
43. printing press management
44. Printing Press Mgmt
45. productin management system
46. Property management
47. purchase system
48. Registration office management system
49. Reliance Gallary Management
50. Remote Desktop VBNET

Hope This Will Help U....
Difference Between Interface and Abstract Class
1. Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behaviour.
2. Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
3. Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
4. Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
5. An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
6. A Java class can implement multiple interfaces but it can extend only one abstract class.
7. Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
8. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
How can we implement an interface in JSP page :
1. Implement interface in a class, then use this class in JSP .
2.
<%!
interface MyInter { 
public String test(); 
}
class InterfaceImpl implements MyInter{ 
public String test(){ 
return "This is from MyInter - The Interface"; 
}
}
%>
<%
InterfaceImpl inter = new InterfaceImpl();
String str = inter.test();
out.println(str);
%>