Monday, 12 February 2018

java full course

Here you can learn c++  ,java,  data structure ,database 
    A complete project of hospital management etc 

Trigger for update in sql server

     
  create trigger updates on stu             
     for update as begin declare
  @id int
  declare @Nname nvarchar(49),@Oname nvarchar(49),
   @Nage int,@Oage int,@Nsalary int,@Osalary int
  ,@ides int  ,@names nvarchar(49),@ages int,@salarys int,@dates nvarchar(30)
 
   select * into #temptable from inserted
   while(exists(select id from #temptable))
   begin
   select top 1 @id=id,@Nname=name,@Nage=age,@Nsalary=salary from #temptable
   select @Oname= name,@Oage=age,@Osalary=salary from deleted
 
   if(@Oname <> @Nname)
   
   set @names=@Nname
   
   if(@Oage <> @Nage)
   
   set @ages=@Nage
   
  if(@Osalary <> @Nsalary)
 
  set @salarys=@Nsalary
   
   set @dates=cast(getdate() as nvarchar(30))
   insert into backs values(@id,@names,@ages,@salarys,@dates)
   delete from #temptable where id=@id
   end
   end
 

Trigger for insert in sql server


    create trigger inserts
    on srudent
    for insert as begin declare
                 @id int,
                 @name nvarchar(30),
                 @gender nvarchar(7),
                 @age int
                 select @id= id ,@name=name,@gender = gender,@age=age from inserted
                 insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
                   end

trigger for delete in sql server

create trigger Deletes
    on srudent
    for delete as begin declare
                 @id int,
                 @name nvarchar(30),
                 @gender nvarchar(7),
                 @age int
                 select @id= id ,@name=name,@gender = gender,@age=age from deleted
                 insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
                   end
   

inner join in sql server

create database shop

use shop

create table product(pid int primary key ,
pname nvarchar(30),
pp int,
sp int)

create table category(id int primary key,pname nvarchar(29))

alter table product add cID int foreign key references category(id)


create proc insrt
@id int,
@name nvarchar(10),
@pp int,
@sp int,
@cID int
as begin 


insert into product values(@id,@name,@pp,@sp,@cID)
end
exec insrt 10,'i phone',33,332,11

update procedure in sql server

/////////////////////////////////****************  Home ***************/////////////////////

import javax.swing.JPanel;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author bilal
 */
public class Home extends javax.swing.JFrame {

    /**
     * Creates new form Home
     */
    public Home() {
        super("Home");
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                       
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        p4 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        p1 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        p2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        p3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jButton4 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

foreign key in sql server

create database shop use shop create table product(pid int primary key ,pname nvarchar(30),pp int,sp int)create table category(id int primary key,pname nvarchar(29))alter table product add cID int foreign key references category(id)


how to print tree in level order c++

#include<iostream>
#include<queue>
using namespace std;

struct tree
{
int num;
tree *left,*right;
}*root;
  void levelOrder(tree *r)
  {
  queue <tree*> q;
  q.push(r);
  while(!q.empty())
  {
   tree *d =q.front();
            q.pop();
            cout<<d->num<<" ";
            if(d->left) q.push(d->left);
            if(d->right) q.push(d->right);
}
 
 
  }
 
 
 
 
 
tree * create(int n)
{
    tree *t = new tree;
    t->left=t->right=NULL;
 
    t->num=n;
    return t;
}

tree * add(tree *r,int n)
{
     if(r==NULL)
     {
        r=create(n);
}
else if(r->num>n)
{
r->right=add(r->right,n);
}
else
r->left=add(r->left,n);
return r;
}
void display(tree * t)
{
       if(t==NULL)
       {
        return ;
   }
   else
   {
     cout<<t->num<<"   ";
     display(t->left);
     display(t->right);
   }
}
int main()
{
     root =NULL;
   
     int n,t;
 while(true)
 {

     cout<<"Enter 1 for add Enter 2 for diplay "<<endl;
  cin>>n;
  switch(n)
  {
    case 1:
    cout<<"Enter the number "<<endl;
    cin>>t;
    root=add(root,t);
    break;
    case 2:
    display(root);
    break;
    case 3:
    levelOrder(root);
    break;
   

}}

add show add delete node from tree

#include<iostream>
using namespace std;
struct tree
{
 int num;
 tree* left,*right;

}*root;
tree * create(int n)
{
 tree *t= new tree;
 t->num=n;
 t->left=t->right=NULL;
 return t;

}
tree * add(tree * r,int nu)
{
      if(r==NULL)
      {
        r= create(nu);
     
   }
   else if(nu<=r->num)
   {
     r->left= add(r->left,nu);
   }
   else
   r->right=add(r->right,nu);
   return r;
}
void disply(tree * t)
{
 if(t==NULL)
 {
  return;
 }
 else
 {
    cout<<t->num<<"   ";
    disply(t->left);
 
    disply(t->right);
 }
 }
tree * deletes(tree * t)
{
while(t->left!=NULL)
{
  t=t->left;
}return t;
}
tree * deleteNode(tree * r,int d)
{
 if(r==NULL)
 {
  return r;
 }
 else if(d<r->num)
 {
  r->left=deleteNode(r->left,d);
 
 }
 else if(d>r->num)
 {
  r->right=deleteNode(r->right,d);
 
 }
 else {
  if(r->left==NULL&&r->right==NULL)
  {
  delete r;
  r=NULL;
}
else if(r->right==NULL)
{
tree * temp;
temp=r;
r=r->left;
delete temp;
}
  else if(r->left==NULL)
{
tree * temp;
temp=r;
r=r->right;
delete temp;
}
else
{
  tree *temp=deletes(r->right);
  r->num=temp->num;
 
  r->right=deleteNode(temp,temp->num);
}

 }
 return r;
}

int main()
{
root==NULL;
int n,a;
while(1){

cout<<"Enter 1 for add Enter 2 for display Enter 3  for delete node"<<endl;
cin>>n;
switch(n)
{
case 1:
 cout<<"Enter the number for add"<<endl;
 cin>>a;
root=add(root,a);
break;
case 2:
  disply(root);
  cout<<endl;
break;
case 3:
cout<<"Enter the number for delete"<<endl;
 cin>>a;
root=deleteNode(root,a);
break;
}


}
}

how to create tree and display all its elements


#include<iostream>
using namespace std;
struct tree
{
 int num;
 tree* left,*right;

}*root;
tree * create(int n)
{
 tree *t= new tree;
 t->num=n;
 t->left=t->right=NULL;
 return t;

}
tree * add(tree * r,int nu)
{
      if(r==NULL)
      {
        r= create(nu);
       
}
else if(nu<=r->num)
{
  r->left= add(r->left,nu);
}
else
r->right=add(r->right,nu);
return r;
}
void disply(tree * t)
{
 if(t==NULL)
 {
  return;
 }
 else
 {
    cout<<t->num<<"   ";
    disply(t->left);
 
    disply(t->right);
 }
 }

int main()
{
root==NULL;
int n,a;
while(1){

cout<<"Enter 1 for add Enter 2 for display"<<endl;
cin>>n;
switch(n)
{
case 1:
cout<<"Enter the number for add"<<endl;
cin>>a;
root=add(root,a);
break;
case 2:
disply(root);
cout<<endl;
break;
}


}
}

game of death in the circlar link list

THis is a death game all the peoples are atand in a circle and start from 1 1 kill the second 3 kill the 4 and so on
this is circular link list the rmaining person is one
  for  Example
     1            2           3       4   
   are stand in a circle
        1        3  are  kill 2 and 4
 and then      1 kill the 3   
#include<iostream>
using namespace std;
int nums=0;
struct death
{
   int num;
   death *next;
}*head,*tail;
void addnumber(int num)
{
nums=num;
  for(int i=1;i<=num;i++)
  {
        death *d= new death;
         if(head==NULL)
         {
         d->num=i;
         head =tail=d;
         tail->next=head;
         }
         else
         {
              d->num=i;
              tail->next=d;
              tail=d;
              tail->next=head;
         }
       
  }

}
void display()
{
death * temp;
temp =head;
    while(temp->next!=head)
    {
        cout<<temp->num<<"    ";
        temp=temp->next;
    }
    cout<<temp->num<<"    ";
    cout<<endl;
}
void playGame()
{
 death * temp,*temp1;
temp =head;
for(int i=0;i<nums;i++)
{


       cout<<temp->num<<"    ";
       temp1= temp->next;
     
       temp->next=temp1->next;
      
        temp=temp->next;
  
        temp1=NULL;
            delete temp1;
      
} cout<<endl;
cout<<"So the remaining number is "<<temp->num<<"    ";
}
int main()
{
    head=tail=NULL;
    int num;
    while(1){
  
    cout<<"Enter the number please "<<endl;
    cin>>num;
    switch(num)
    {
       case 1:
           int num1;
           cout<<"Enter the number of persons in this game"<<endl;
           cin>>num1;
         
           addnumber(num1);
           break;
           case 2:
               display();
               break;
               case 3:
     playGame();
     break;
                   
    }}
}                               
                                           https://getcryptotab.com/900383

a program that convert decimal to using recursion

#include <iostream>
using namespace std;
void decToBin(int num, int base);
int main()
{
int decimalNum;
int base;
base = 2;
cout << "Enter number in decimal: ";
cin >> decimalNum;
cout << endl;
cout << "Decimal " << decimalNum << " = ";
decToBin(decimalNum, base);
cout << " binary" << endl;
return 0;
}
void decToBin(int num, int base)
{
if (num > 0)
{
decToBin(num / base, base);
cout << num % base;
}
}

program that convert decimal number into binary

#include<iostream>
using namespace std;
struct decimal
{
  int num;
  decimal *next;
 
}*head;
void convert( int num)
{ decimal  * d= new decimal ;

     while(num!=0)
    
     {
     decimal  * d= new decimal ;
        d->next=NULL;
     if(head==NULL)
{
            d->num=num%2;
      head=d;
      num/=2;
     }
     else {
      d->num=num%2;
      d->next=head;
      head=d;
   
      num/=2;
     }
   
}}
void display()
{
 decimal * temp;
 temp=head;

 while(temp!=NULL)
 {
   cout<<temp->num;
   temp=temp->next;
 }
}

int main()
{  head =NULL;
     int num;
     cout<<"Enter the number please "<<endl;
     cin>>num;
     cout<<"The decimal in binary =";
    convert(num);
    display();
}

Honoli tower problem in data structure

#include<iostream>
using namespace std;
void HanoliTower(int numf,string a,string b,string c)
{
  if(numf==1)
  {
        cout<<"Move Plate "<<numf<<" from "<<a<<"  to "<<c<<endl;

  }
  else {
 
  HanoliTower(numf-1,a,c,b);
 
  cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;

      HanoliTower(numf-1,b,a,c);
      }
}
int main()
{
    HanoliTower(3,"Tower 01","Tower 02","Tower 03");

}

how to sum of numbers using recursion

#include<iostream>
using namespace std;
int sum(int num)
         if(num==0)
         return 0;
         else return num+sum(num-1);
}
int main()
{
int n;
cout<<"Enter any number please"<<endl;
cin>>n;
cout<<"factorial is "<<sum(n)<<endl;
}

how to connect java with sqlite database

who to///////////////////******************* Java Connector ***************////////////////////////

           

import java.sql.*;

import javax.swing.*;

public class connector {

    

    Connection cn=null;

    public static Connection connectorBD()

    { 

        try 

        {

            Class.forName("org.sqlite.JDBC");

            Connection cn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\bilal\\Documents\\NetBeansProjects\\HospitalManagementSystem\\HospitalManament.sqlite");//Here you past your address

         

            return cn;

        }

        catch(Exception e)

        { 

            JOptionPane.showMessageDialog(null, e);

            return null;

        }

    }

}