Question
HELP! HI, I am supposed to create a 2d array with the alphabet shown below, I was able to get the table exactly but I
HELP! HI, I am supposed to create a 2d array with the alphabet shown below, I was able to get the table exactly but I am not using the methods as I am supposed to... here ir what I have so far please help:
public class Lab02 { public static void main(String [] args) {
// Create an array that will hold the grid char alphabetTable[][] = populateLookUpTable();
// Two for loops to print the grid on the screen for(int i=0; i<26; i++) { for(int j=0; j<26; j++) { System.out.print(alphabetTable[i][j]); } System.out.println(); }
} // end of main
// Create a function to generate the grid public static char[][] populateLookUpTable(){ char[][] arr = new char[26][26];
// Two for loops to generate the grid for(int i = 0; i < 26; i++) { for(int j = 0; j < 26; j++) {
// Creates an int that will later be cast to a char int let = i + j;
// Keeps the int from getting too big if(let >= 26) let = let - 26;
// Add 65 to the int so that the char will return letters and not ASCII symbols let = let + 65;
// Cast the int to a char char letter = (char)let;
// Put the char into its respective place in the array arr[i][j] = letter;
} } // Returns the grid return arr; }
Method Implementation Write a class called Lab02.java, where you will implement the following methods in addition to test your programs. Use the Lab02Tester.java file to demonstrate your Lab. populateLookUpTable(): This method will generate a n x n look up table containing the mapping for the alphabet. You can assume that the table is based on English, which has 26 letters, i.e., n = 26. Notice that depending on the language, the value of n varies. print(): Method will take an array of characters as an argument and it will print in matrix form as follows.
a b c d e f g h i j k l m n o p q r s t u v w x y z b c d e f g h i j k l m n o p q r s t u v w x y z a c d e f g h i j k l m n o p q r s t u v w x y z a b d e f g h i j k l m n o p q r s t u v w x y z a b c e f g h i j k l m n o p q r s t u v w x y z a b c d f g h i j k l m n o p q r s t u v w x y z a b c d e g h i j k l m n o p q r s t u v w x y z a b c d e f h i j k l m n o p q r s t u v w x y z a b c d e f g i j k l m n o p q r s t u v w x y z a b c d e f g h j k l m n o p q r s t u v w x y z a b c d e f g h i k l m n o p q r s t u v w x y z a b c d e f g h i j l m n o p q r s t u v w x y z a b c d e f g h i j k m n o p q r s t u v w x y z a b c d e f g h i j k l n o p q r s t u v w x y z a b c d e f g h i j k l m o p q r s t u v w x y z a b c d e f g h i j k l m n p q r s t u v w x y z a b c d e f g h i j k l m n o q r s t u v w x y z a b c d e f g h i j k l m n o p r s t u v w x y z a b c d e f g h i j k l m n o p q s t u v w x y z a b c d e f g h i j k l m n o p q r t u v w x y z a b c d e f g h i j k l m n o p q r s u v w x y z a b c d e f g h i j k l m n o p q r s t v w x y z a b c d e f g h i j k l m n o p q r s t u w x y z a b c d e f g h i j k l m n o p q r s t u v x y z a b c d e f g h i j k l m n o p q r s t u v w y z a b c d e f g h i j k l m n o p q r s t u v w x z a b c d e f g h i j k l m n o p q r s t u v w x y
filloutBuffer():The method performs the filling mechanism between the original string and the key. The method shall take two parameters: o original: a string that is the original message to be encrypted o key: a string that corresponds to the sting that will be fill-out with the length of the original message The method shall return a two-dimensional array of characters, where each index of the first row corresponds to each character of the original string, and each index of the second row corresponds to each character of the key string, repetitively until the row is filled out. The method shall throw a LargerKeyException, notifying that the key is larger than the message E.g., if the original string message is THISISAMESSAGE and the key is HELLO, the corresponding two-dimensional array of characters looks as follows: T H I S I S A M E S S A G E
3
mapCharacters(): The purpose of this method is to find the corresponding character based on two characters. The method will take: o c1: a character, which position in the first row would be mapped o c2: a character, which position in the first column would be mapped o table: a 2-dimensional array of character, corresponding to the look up table The method shall return a character, corresponding to the mapping between the first character c1 and the second character c2 from the look up table.
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