Skip to content

Commit 0f8b775

Browse files
authored
Add files via upload
1 parent 615c5a1 commit 0f8b775

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

JavaArray04.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*Task 4
2+
Write a Java program that takes a string input in small letters from the user and prints the previous alphabet in sequence for each alphabet found in the input.
3+
4+
Sample Input Output
5+
wxyz vwxy
6+
thecow sgdbnv
7+
abcd zabc */
8+
9+
import java.util.Scanner;
10+
public class JavaArray04{
11+
public static void main(String [] args){
12+
Scanner sc= new Scanner(System.in);
13+
String st1=sc.nextLine();
14+
String emp="";
15+
for(int i=0;i<st1.length();i++){
16+
char ch=st1.charAt(i);
17+
if(ch=='a'){
18+
ch='z';
19+
emp+=ch;}
20+
else{
21+
int val=(int) ch;
22+
ch=(char)(val-1);
23+
emp+=ch;}}
24+
System.out.println(emp);
25+
}
26+
}
27+

0 commit comments

Comments
 (0)