I need to use the IO module for this. I am new to programming so basic syntax pl
ID: 3762585 • Letter: I
Question
I need to use the IO module for this. I am new to programming so basic syntax please. If you could include comments as to what you did that would be extremly helpful. Thanks in advance.
Your program should take a string that has been encoded using a "secret" code, and decode it. The code works as follows: Each letter is decoded using the letter immediately preceding it in the alphabet. "b" becomes "a", "c" becomes "b", etc. The letter "a" becomes "z". Each digit is decoded using the preceding digit. "1" becomes "0", "2" becomes "1", etc. The digit "0" becomes "9". Characters that are neither letters nor digits are unchanged. Regardless of whether the input string contains upper- or lowercase characters, the output (one string) should be in all lowercase. Example: java Cipher NFFU NF BU 23 JO UIF CFMM UPXFS RESULT: "meet me at 12 in the bell tower"
Explanation / Answer
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;
/**
*
* @author Rajeev
*/
public class Decode {
public static void main(String[] args)
{
for(int i=0;i<args.length;i++)
{
StringBuilder temp = new StringBuilder(args[i]);
for(int j=0;j<args[i].length();j++)
{
char ch = temp.charAt(j);
if(ch>='A' && ch<='Z')
{
int jk =(int)ch;
jk = (jk - 'A' +25)%26 + 'a' ;
ch = (char)jk;
}
else if(ch>='a' && ch<='a')
{
int jk =(int)ch;
jk = (jk - 'a' +25)%26 + 'a' ;
ch = (char)jk;
}
else if(ch>='0' && ch<='9')
{
int jk =(int)ch;
jk = (jk - '0' +9)%10 + '0' ;
ch = (char)jk;
}
temp.setCharAt(j, ch);
}
System.out.print(temp);
if(i<args.length-1)
{
System.out.print(" ");
}
}
}
}