icse-promo

Question

 Write a program to accept a word and convert it into lowercase if it is in uppercase, and display the new word by replacing only the vowels with the character following it.

				
					Example:
Sample Input : computer
Sample Output : cpmpvtfr
				
			

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					import java.util.Scanner;

public class program7
{
    public static void main(String[]args)
    {
        int i=0,len=0;
        char ch=' ';
        String wd="";
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a String: ");
        wd = sc.next();
        wd= wd.toLowerCase();
        String wd1 = "";
        len=wd.length();
        for (i = 0; i < len; i++)
        {
            ch = wd.charAt(i);
            if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
            {
                wd1 =wd1 + (char) (ch + 1);
            }
            else
            {
                wd1 =wd1 + ch ;
            }
        }
        System.out.println(wd1);
    }

}

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *