Question
In cryptograms, each character is encoded into another. The frequency of letters in text has been studied for use in cryptanalysis, and frequency analysis in
In cryptograms, each character is encoded into another. The frequency of letters in text has been studied for use in cryptanalysis, and frequency analysis in particular, dating back to the Iraqi mathematician Al-Kindi (c. 801-873 AD), who formally developed the method (the ciphers breakable by this technique go back at least to the Caesar cipher invented by Julius Caesar, so this method could have been explored in classical times). If the text is long enough, one can, as a strategy, use the frequency of occurrence of each character. The most frequently occurring character will likely be the code for an e, because e is the most frequently used letter of the English alphabet. Design a class Named CryptGram.java with the following requirements: Data Members: a Letter(it is provided) array named orderedFrequency to store frequency of the 26 alphabetic letters. (Letter[] orderedFrequency;) Methods: public void createLetterFrequency(String text) public int getFrequencyByChar(char letter) public String encode(String textToBeEncoded) public String decode(String textToBeDecoded) The method: createLetterFrequency, create the letter frequency from the argument passed to this method, the letter frequency array MUST by sorted by frequency, for example, the first three Letter elements in the array may look like: d[2], r[5], a[6], which means d appears in the file twice, r five time, and a six times. If the frequencies are ties, then being ordered by alphabetic order. For instance, e[9] and c[9], c[9] should be placed before e[9]. The method: getFrequencyByChar, returns the number of times the char passed as argument appears in the file The method: encode, encodes the String and returns encoded String. The text to be encoded is encrypted as follows: each character in the text will be encrypted to the character in the letter frequency array: orderedFrequency. For example, letter a or A will be encrypted to the letter of the first element in the orderedFrequency array. The letter z or Z will be encrypted to the letter of the last element in the orderedFrequency array. The method: decode, reverse the encode process and decrypt the text (ignore cases)
given
FrequencyEncrypt.java
import java.io.*;
public interface FrequencyEncrypt{ void createLetterFrequency(String str); int getFrequencyByChar(char letter); String encode(String textToBeEncoded); String decode(String textToBeDecoded); public final String TEXT="A Tool to Perform Item Analysis to Enhance the Teaching and Learning Experiences ADSTRACT: "+ "Assessment is one of the most essential educational tools. When properly developed and interpreted, assessments can help "+ "instructors better understand what their students are learning, identify specific areas which need clarification, and hence "+ "improve both teaching and learning experiences. Item analysis is a widely used tool to assess learning outcomes. It provides "+ "the means to gather evidence about students? knowledge on specific topics or knowledge areas. It can be used to identify students?"+ " strengths and weakness, monitor student learning and progress, and plan and conduct instruction. However, due to cumbersomeness of "+ "calculating relevant statistics, some best practices in item analysis are too infrequently used in actual practice. This paper describes "+ "an embedded item analysis tool that is integrated into the online programming assignment management and auto-grading system, and how it "+ "is used to assess students? learning outcomes and enhance teaching and learning experiences."; }
Letter.java
public class Letter implements Comparable
public int compareTo(Letter letter){ if(frequency != letter.frequency) return frequency-letter.frequency; else return (int)this.letter - (int)letter.letter; } public char getChar(){ return letter;} public int getFrequency(){ return frequency;} public void incrementFrequency(){ frequency++; } }
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