@@ -49,11 +49,19 @@ public static String modifyMessage(String message, String polynomial) {
4949 return message ;
5050 }
5151
52+ // Passing Through Noisy Channel
53+ public static String noisyChannel (String msgToBeTransmitted ) {
54+ StringBuilder noise = new StringBuilder (msgToBeTransmitted );
55+ noise .setCharAt (msgToBeTransmitted .length ()/2 , '1' );
56+ String noisyData = noise .toString ();
57+ return noisyData ;
58+ }
59+
5260
5361 public static void main (String [] args ) {
5462 Scanner sc = new Scanner (System .in );
5563 System .out .print ("Enter the Data(Message) to be Encrypted: " ); // Original Message
56- String message = sc .next (); // Test --> 1010000
64+ String message = sc .next (); // Test --> 1010000 , 100100111
5765
5866 System .out .print ("Enter the CRC Generator(Polynomial): " ); // CRC Generator
5967 String polynomial = sc .next (); // Test --> 1001
@@ -64,19 +72,19 @@ public static void main(String[] args) {
6472 String msgToBeTransmitted = generateCRC_CheckBits (modified_message , polynomial );
6573 System .out .println ("\n Data(Message) is ready to be Transmitted: " + msgToBeTransmitted );
6674
67- System . out . print ( "Enter the Data(Message) to be Transmitted: " );
68- String send_data = sc . next ( );
75+ String send_data = noisyChannel ( msgToBeTransmitted );
76+ System . out . println ( "Data(Message) Transmitted through Noisy Channel: " + send_data );
6977
7078 String checkAllZeroes = xorOperation (send_data ,polynomial );
7179
7280// It checks if the remainder contains only zeroes --> If it contains only zeros then the data/message is accepted else considered as error in Transmission
7381 for (int i = 0 ; i < checkAllZeroes .length (); i ++) {
7482 if (checkAllZeroes .charAt (i ) == '1' ) {
75- System .out .println ("Error in Transmission!" );
83+ System .out .println ("\n Error in Transmission!\n " );
7684 return ;
7785 }
7886 }
7987
80- System .out .println ("No! Error in Transmission! " );
88+ System .out .println ("\n Data(Message) Transmitted Successfully! \n " );
8189 }
8290}
0 commit comments