Input
Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.
Output
You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.
Sample Input
O S, GOMR YPFSU/
Sample Output
I AM FINE TODAY.
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.*; import java.lang.*; import java.math.*; public class Mock3{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); String line =System.getProperty("line.separator"); scan.useDelimiter(line); String get = scan.next(); String str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; String ans=""; for(int x=0;x<get.length();x++){ if(get.charAt(x) != ' '){ for(int y=0;y<str.length();y++){ if(get.charAt(x) == str.charAt(y)){ ans = ans +""+ str.charAt(y-1); break; } } } else{ ans = ans + " "; } } System.out.print(ans); } } |
No comments:
Post a Comment