Question: What does the program do? How can the program be fixed? How could the program be improved? This is the code: public class BigMain {
What does the program do? How can the program be fixed? How could the program be improved?
This is the code:
public class BigMain {
public static void main(String[] args) {
String secret = "jihgfedcba9yxwvutsrqponmlk";
String clear = "";
for(int i = secret.length() - 1; i >= 0; i--) {
char c = secret.charAt(i);
int newPosition = Character.getNumericValue(c) - 9;
newPosition = (newPosition - 10);
if(newPosition <= 0) {
newPosition += 26;
}
clear = clear + Character.forDigit(newPosition + 9, 36);
}
// clear should read 'abcdefghijklmnopqrstuvwxyz'
System.out.println("'" + secret + "' equates to ... " + clear);
secret = "im9cyxoosqrd";
clear = "";
for(int i = secret.length() - 1; i >= 0; i--) {
char c = secret.charAt(i);
int newPosition = Character.getNumericValue(c) - 9;
newPosition = (newPosition - 10);
if(newPosition <= 0) {
newPosition += 26;
}
clear = clear + Character.forDigit(newPosition + 9, 36);
}
// clear should read 'cpsoneeighty'
System.out.println("'" + secret + "' equates to ... " + clear);
}
}
This is secret1.txt:
ynivnodko9obogdkrgobkog
dmkxkdyxcsomxovvomho
dslkrkcsds
deyqxsfsvkoukwog
ynogdkrgpy
deyopsvkoukwog
ofsqogdkrgpy
This is secret2.txt:
nbycockbobo
ofsyvodckbolve
csmkxnomynowocckqo
erygklyediy
im9cyxoosqrd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
