Question: Written in java When you have finished creating the alpha array and the random alpha array create methods to display the current cipher, accept a

Written in java

When you have finished creating the alpha array and the random alpha array create methods to display the current cipher, accept a new predefined cipher that will be loaded as the active cipher and then the encrypt and decrypt methods. Make a menu system to bring all the parts together.

So you create an array with the alphabet and then an encrypted version. The user can enter a sentence and then you return the encrypted code. They can also ask for the decrypted version. I need help adding the menu system, fixing the error, returning the encrypted code, encrypting the code, etc.

Heres what I have so far. There's an error thrown and it's not complete.

public class cipherciph { private String statement; public String go(String state) { statement = state; String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String beta = ""; int n = 26; for (int j = 0; j int index = (int)(n * Math.random()); beta = beta + alpha.charAt(index); alpha = alpha.substring(0,index) + alpha.substring(index+1); n--; } int val1; String code = ""; for (int val = 0; val val1 = alpha.indexOf(statement.charAt(val)); code = Character.toString(beta.charAt(val1)); } return code; } }

Here's the runner:

import java.util.Scanner; public class cipherRun { public static void main( String[] args ) { cipherciph n = new cipherciph(); Scanner in = new Scanner (System.in); String statement = in.nextLine(); System.out.println (n.go(statement)); } }

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 Programming Questions!