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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started