Java Program for block parity

/*java program for block parity or double parity (block parity).
Calculating each column of multiple messages to check if it is even or odd. In Case of even value add 1 otherwise 0 to make even parity of column 
eg.
10110101
11110011
_________
01000110
*/
import java.util.*;
class DjParity1
{
int i,j,k,l;
String ans="";

public void blockParity()
{
System.out.println("How many message you want to send: ");
Scanner s=new Scanner(System.in);
i=s.nextInt();

String msg[]=new String[i];
Scanner s1=new Scanner(System.in);
for(j=0;j<i;j++)
{
System.out.println("Enter your msg value[0/1] 8 bit: ");
msg[j]=s1.nextLine();
}

for(k=0;k<msg[0].length();k++)
{
//System.out.println("hello "+msg[k]);
int a=0;
for(l=0;l<i;l++)
{
a+=msg[l].charAt(k);
//System.out.println("Your msg: "+msg[l]);
}
if(a%2==0)
{
ans+="0";
}
else
{
ans+="1";
}
}
System.out.println("ans: "+ans);
}
}
class DjBlockParity
{
public static void main(String args[])
{
DjParity1 obj=new DjParity1();
obj.blockParity();
}
}

Comments

Popular posts from this blog

Rumored Sony Honami mini won't downsize the specs

Movie review on 'Jobs' biopic in opening weekend

Lg acceses Samsung galsxy s4 of violating its eye-tracking patent