Pls share code in java

Write a program that forms a new sentence upon taking an input string as per
the below algorithm
• Shift the alphabets N number of times in FORWARD mode, where N is
the length of a particular word in the given String.
input1: Hi Hell
output: Jk Lipp
Explanation: H and i in the word “Hi” is shifted 2 times forward as the length
of “Hi” is 2
All the alphabets in the word “Hell” are shifted 4 times forward as the length
of “Hell” is 4
If the alphabet reaches the end of the series, then it should be replaced
with z or Z, depending on its case.

input1: ABCDX
output: FGHIZ
Explanation: When the last alphabet x needs to be shifted 5 times forward but
the alphabets end at Z, X is replaced by Z.

String may contain lowercase and uppercase letters, which needs to be
replaced in respective cases.

Prototype: String returnTheModified Sentence(String input1)

Few more examples:
input1: GO INDIA
output: IQ nSINE

1 Like