To encrypt a character using this model find the character o

To encrypt a character using this model, find the character on the inner rotor (i.e., the inside ring) and note the character aligned with it on the outer rotor (i.e., the outside ring), then find that character on the middle rotor (i.e., the middle ring) and output the one aligned with it on the outer rotor. After a character is encrypted, turn the inner rotor clockwise one step. Whenever the inner rotor returns to its original orientation, the middle rotor turns once in lock-step, just like the odometer in a car. For example, in this configuration the character \'A\' would be encrypted as \'N\' since \'A\' on the inner rotor is aligned with \'H\' on the outer rotor, and \'H\' on the middle rotor is aligned with \'N\' on the outer rotor. After performing this encryption, the inner rotor is rotated clockwise, so the letter \'A\' would next be encrypted as \'D\'. SAMPLE ONLY -each wheel to map the A-z, and spaces (#) total of 27 spaces per wheel. For Ease of Remembering - (Plugboard) Inner, outer, middle, outer (plugboard) to trace the encrypted character Note that decrypting a message requires following the same steps, only in reverse (i.e., plugboard, find the character on the outer rotor, note the character aligned with it on the middle rotor, find that character on the outer rotor, then output the character aligned with it on the inner rotor, then plugboard).

Solution

import java.util.Scanner;

public class chegg {

   public static void main(String[] args) {
       char inner []=new char[]{\'#\',\'G\',\'N\',\'U\',\'A\',\'H\',\'O\',\'V\',\'B\',\'I\',\'P\',\'W\',\'C\',\'J\',\'Q\',\'X\',\'D\',\'K\',\'R\',\'Y\',\'E\',\'L\',\'S\',\'Z\',\'F\',\'M\',\'T\'};
       char   middle[]={\'#\',\'E\',\'J\',\'O\',\'T\',\'Y\',\'C\',\'H\',\'M\',\'R\',\'W\',\'A\',\'F\',\'K\',\'P\',\'U\',\'Z\',\'D\',\'I\',\'N\',\'S\',\'X\',\'B\',\'G\',\'L\',\'Q\',\'V\'};

       char outer[] = {\'#\',\'B\',\'D\',\'F\',\'H\',\'J\',\'L\',\'N\',\'P\',\'R\',\'T\',\'V\',\'X\',\'Z\',\'A\',\'C\',\'E\',\'G\',\'I\',\'K\',\'M\',\'O\',\'Q\',\'S\',\'U\',\'W\',\'Y\'};

       Scanner kb = new Scanner(System.in );
       String input = kb.nextLine();
       char c ,midc = \'\\0\';
       int v=0;
       String output=\"\";
       for(int i =0;i <input.length();i++){
           c= input.charAt(i);
           if(i>26){
               v++;
           }
           if(c==\' \'){
               output+=\"#\";
               continue;
           }
           for(int y=0;y<=26;y++){
               if (c==inner[y]){
                   midc = outer[y+i];
               }
           }
           for(int y =0 ; y <=26;y++){
               if(midc==middle[y]){
                   output+=outer[y+v];
               }
           }

       }
       System.out.println(output);

   }

}

 To encrypt a character using this model, find the character on the inner rotor (i.e., the inside ring) and note the character aligned with it on the outer roto

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site