Posts

Showing posts from February, 2017

JQuery Slider

Jquery slider <!doctype html> <html>   <head>     <meta charset="utf-8">     <title>jQuery Image Slider</title>     <link rel="stylesheet" href="bjqs.css">     <link href='http://fonts.googleapis.com/css?family=Source+Code+Pro|Open+Sans:300' rel='stylesheet' type='text/css'>     <link rel="stylesheet" href="demo.css">     <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>     <script src="js/bjqs-1.3.min.js"></script>   </head>   <body>     <div id="container">         <h2>Image Slider Using jQuery</h2>       <div id="banner-slide">         <ul class="bjqs">      ...

Hamming code in java

Image
Hamming Code  import java.util.*; class Hamming { public static void main(String args[]) { Scanner scan = new Scanner(System.in); System.out.println("Enter the number of bits for the Hamming data:"); int n = scan.nextInt(); int a[] = new int[n]; for(int i=0 ; i < n ; i++) { System.out.println("Enter bit no. " + (n-i) + ":"); a[n-i-1] = scan.nextInt(); } System.out.println("You entered:"); for(int i=0 ; i < n ; i++) { System.out.print(a[n-i-1]); } System.out.println(); int b[] = generateCode(a); System.out.println("Generated code is:"); for(int i=0 ; i < b.length ; i++) { System.out.print(b[b.length-i-1]); } System.out.println(); System.out.println("Enter position of a bit to alter to check for error detection at the receiver end (0 for no error):"); int error = scan.nextInt(); if(error != 0) { b[error-1] = (b[er...

Bully Algorithm in Java program

Image
BULLY ALGORITHM import java.io.*; import java.util.*; class ba { public static int np[]=new int[10]; public static int priority[]=new int[10]; public static int status[]=new int[10]; public static int n,i,p,c,ch; public static int crash,recover,ele,co; public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println("Enter the number of process = "); n=sc.nextInt(); //Scanner sc=new Scanner(System.in); System.out.println("Enter the priority for"+n+" processes \n"); for(i=0;i<n;i++) { System.out.println("Priority for process"+(i+1)); p=sc.nextInt(); priority[i]=p; } for(i=0;i<n;i++) { status[i]=1; } do { System.out.println("1.crash 2.Recovery 3.exit"); System.out.println("Enter your Choice = "); ch=sc.nextInt(); switch(ch) { case 1: System.out.println("Which process you want to crash = "); crash=sc.nextInt(); status[(crash-1)]=0; System.out....

Centralized Mutual Exclusion

Image
Centralized Mutual Exclusion import java.io.*;  class pc { public int flag=0; public int front=0; public int rear=-1; public boolean grant; int[] queue=new int[10]; public void request(int p) { System.out.println("process "+p+ " entered"); if(flag==0) { System.out.println("reply to process = "+p); flag=1; } else { if(flag==1) { System.out.println("wait process = "+p); rear++; queue[rear]=p; } } } public void release(int p) { flag=0; if(queue[front]!=0) { System.out.println("released process = "+p); System.out.println("delete from queue process = "+queue[front]); request(queue[front]); front=front+1; } } } public class cendist extends pc { public static void main(String args[]) throws IOException { cendist p1=new cendist(); p1.request(10); p1.request(11); p1.request(12); p1.release(10); p1.release(11); p1.release(12); } } Output