-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboard.java
More file actions
34 lines (30 loc) · 846 Bytes
/
Keyboard.java
File metadata and controls
34 lines (30 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
public class Keyboard
{
public static void main( String[] args )
{
Scanner s = new Scanner( System.in );
String seq = "qwertyuiopasdfghjkl;zxcvbnm,./";
String d = s.next();
String word = s.next();
StringBuilder sb= new StringBuilder();
int n = word.length();
if(d.equals( "R"))
{
for(int i=0;i<n;i++)
{
int index = seq.indexOf( word.charAt( i ));
sb.append( seq.charAt( index-1 ) );
}
}
if(d.equals( "L"))
{
for(int i=0;i<n;i++)
{
int index = seq.indexOf( word.charAt( i ));
sb.append( seq.charAt( index+1 ) );
}
}
System.out.println( sb );
}
}