Posts

Showing posts from March, 2021

Java Program to replace vowel with next immediate character alphabetically in a String.

Image
  import  java.util.Scanner; class   ReplaceVowel { public   static   void   main ( String []  arg ) { Scanner   sc  =  new   Scanner ( System . in ); //Ask for user input System . out . print ( "Enter String" ); String   str =  sc . nextLine (); //Converting the string into UPPER CASE String   str1 = str . toUpperCase ();   //Converting String 'str1' into character Array  char []  ch  =  str1 . toCharArray (); for ( int   i = 0  ;i< ch . length - 1 ;i++) {      // checking for 'vowel'     if (ch[i]== 'A'  || ch[i]== 'E'  || ch[i]== 'I'  || ch[i]== 'O'  || ch[i]== 'U' )     {         // if vowel found then increase 1 in the A...

Java Program to count and output the number of double letter sequences that exist in the string.

Image
  import  java.util.Scanner; class   DoubleFrequencyLetter { public   static   void   main ( String []  arg ) { Scanner   sc  =  new   Scanner ( System . in ); //Ask for user input System . out . print ( "Enter String" ); String   str =  sc . nextLine (); //initialise the variable 'count' as 0 int   count = 0 ; // convert the string into UPPER CASE and store it in a String 'str1' String   str1 = str . toUpperCase (); for ( int   i = 0  ;i< str1 . length ()- 1 ;i++) {    //check whether the two adjacent characters are same and increase the count      if ( str1 . charAt (i)== str1 . charAt (i+ 1 ))     {          count++;     ...

Java Program to Convert String into PigLatin encoding.

Image
  import  java.util.Scanner; class   PigLatin { public   static   void   main ( String []  arg ) { Scanner   sc  =  new   Scanner ( System . in ); System . out . print ( "Enter String" ); String   str =  sc . nextLine ();     //Converting the string into UpperCase String   str1 = str . toUpperCase (); for ( int   i = 0  ;i< str1 . length ();i++) {    if ( str1 . charAt (i)== 'A' || str1 . charAt (i)== 'E' || str1 . charAt (i)== 'I' || str1 . charAt (i)== 'O' || str1 . charAt (i)== 'U' )     {           System . out . print ( str1 . substring (i)+ str1 . substring ( 0 ,i)+ "AY" );           break ;         } }      } }

Java Program to remove the duplicate characters from the string

Image
  import  java.util.Scanner; class   RemoveDuplicateCharacter { public   static   void   main ( String []  arg ) {    //Ask user to inter a string  Scanner   sc  =  new   Scanner ( System . in ); System . out . print ( "Enter String" ); String   str =  sc . nextLine (); String   str1 = "" ; for ( int   i = 0  ;i< str . length ();i++) {    //Store one-one character from 'Str' to 'Str1' and replace it by space  //in the original string 'str'    if ( str . charAt (i)!= ' ' )     {        str1=str1+ str . charAt (i);        str= str . replace ( str . charAt (i), ' ' );     } }    //printing the final string removing...

Java Program to find the minimum and maximum palindrome String in a Sentence

  class   minMaxPalindrome { public   static   void   main ( String  []  arg ) { String   str  = "wow you kaya a kayak" ; //convert the string into String Array by using Split function String []  str1 = str . split ( " " ); //Initialize the 'length' and 'max' value as 0 int   length = 0 ; int   max = 0 ; //Initialize the 'min' value as the first string of String Array 'str1' int   min =str1[ 0 ]. length (); int  f     //flag variable int   i , j , k ; String   word ,  maxpalindrome = "" , minpalindrome= "" ; for (i= 0 ;i< str1 . length ;i++) {        f= 0 ;      //finding the palindrome string from the String Array 'Str1...

Java Program to Check if a Given String is Palindrome.

Image
Program to Check if a Given String is Palindrome import  java.util.Scanner; public   class   PalindromeString {      public   static   void   main ( String []  arg )      {          int   i , j ;          //Ask for user input and store in a String 'Str'          System . out . print ( "Enter String: " );          Scanner   sc  =   new   Scanner ( System . in );          String   Str  =  sc . nextLine ();          //Store the last position of string in the variable 'last'           ...

Java program to make the first letter of a String capital.

Image
import  java.util.Scanner; import  java.lang.Character; public   class   stringUpperCase {      public   static   void   main ( String []  arg )      {          //Creating Object for Scanner Class          Scanner   sc  =   new   Scanner ( System . in );                   //Ask for User Input String and store in a String 'Str'          System . out . print ( "Enter String: " );          String   Str  =  sc . nextLine ();                   //Adding blank space...