Tarkvara kvaliteet ja standardid projekt
char c = plainText.charAt(x);
if (Character.isLetter(c))
if (c + rotation >= 97)
c = (char) (97 + (c + rotation - 97) % 26);
else
c = (char) (c + (rotation % 26));
encrypted += c;
}
return encrypted;
}
/**
* Finds the most frequently occurring letter in text.
* @param text either plain or encrypted text.
* @return the most frequently occurring letter in text.
*/
public static String findMostFrequentlyOccurringLetter(String text) {
if (text == null)
return null;
if (text.isEmpty())
return text;
String max = "";
int count = 0;
int max_nr = 0;
text = text.toLowerCase();
for (int x = 0; x < text.length(); x++) {
char c = text.charAt(x);
count += 1;
for (int y = x + 1; y < text.length(); y++) {
char ch = text.charAt(y);
if (c == ch)
count++;
}
if (count == max_nr) {