Program to find the Encrypted word | Java program to implement the above approach ; Static function declared to find the encrypted string ; Character array to store the encrypted string ; after ' z ' , it should go to a . ; storing the character array in the string . ; Driver code
import java . util . * ; import java . io . * ; class GFG { public static void findWord ( String c , int n ) { int co = 0 , i ; char s [ ] = new char [ n ] ; for ( i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) co ++ ; else co = n - i ; if ( ( c . charAt ( i ) + co ) <= 122 ) s [ i ] = ( char ) ( ( int ) c . charAt ( i ) + co ) ; else s [ i ] = ( char ) ( ( int ) c . charAt ( i ) + co - 26 ) ; } String str = Arrays . toString ( s ) ; System . out . println ( str ) ; } public static void main ( String args [ ] ) { String s = " abcd " ; findWord ( s , s . length ( ) ) ; } }