Latin alphabet cipher | Java program to demonstrate Latin Alphabet Cipher ; function for calculating the encryption ; Driver Code
class LatinCipher { static void cipher ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( ! Character . isLetter ( str . charAt ( i ) ) && str . charAt ( i ) != ' ▁ ' ) { System . out . println ( " Enter ▁ only ▁ alphabets ▁ and ▁ space " ) ; return ; } } System . out . println ( " Encrypted ▁ Code ▁ using ▁ Latin ▁ Alphabet " ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) >= ' A ' && str . charAt ( i ) <= ' Z ' ) { System . out . print ( str . charAt ( i ) - ' A ' + 1 + " ▁ " ) ; } else if ( str . charAt ( i ) >= ' a ' && str . charAt ( i ) <= ' z ' ) { System . out . print ( str . charAt ( i ) - ' a ' + 1 + " ▁ " ) ; } if ( str . charAt ( i ) == ' ▁ ' ) System . out . print ( str . charAt ( i ) ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; cipher ( str ) ; } }