Take FREE!! Online Cocubes Mock Test to Crack various Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Take 30+ FREE!! Online Arithmetic Aptitude Mock test to crack any Exams.

Program Discussion :: Basics

Home > Programs > Basics

6 / 265

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:

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: