Program Discussion :: Basics
Home > Programs > Basics

6. Write a program to transform strings of lowercase alphabet characters by replacing each letter
with the subsequent character in the english alphabet.

Answer:

package com.pckg;

import java.util.Scanner;

public class SubsequenceCharacter {
    public static void main(String[] args) {
        System.out.println("Enter String  : ");
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String newString = "";
        for (int i = 0; i < str.length(); i++  ) {
            int ascii = (int)str.charAt(i);
            char newChar = (char)(ascii +  1);
            newString = newString   newChar;
        }
        System.out.println("New String : " + newString);
    }
}

Asked In ::  IBM  

Post Your Answer Here:

Name *
Email

Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here: