Question: Hi, I am coding an alternating encryption program. I found this online but want to understand it before I use it. Can someone who is

Hi, I am coding an alternating encryption program. I found this online but want to understand it before I use it. Can someone who is more proficient in Java explain what is going on here? This is supposed to be going through each column from top to bottom, then next column bottom to top and printing one character from a user's input message.

String encrypted = "";

for(int j=0;j

for(int i=0;i

encrypted+=(j%2==0)?grid[i][j]:grid[rows-1-i][j];

if(j!=cols-1) encrypted+=" ";

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!