1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
public class Test {
public static char alpha [] = {'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'};
public static boolean encore = true;
public static void main (String [] args) {
Scanner sc = new Scanner (System.in);
System.out.println ("Tapez \"/h\" pour voir la liste des commandes");
while (encore) {
System.out.print(">");
String command = sc.nextLine();
Command(command, sc);
}
}
public static void Cesar (Scanner sc) {
System.out.print("Votre texte : ");
String texte = sc.nextLine();
texte = texte.toUpperCase();
for (int i = 0; i < texte.length(); i++) {
if (alpha.contains(texte.charAt(i))) {
char letter = texte.charAt(i);
int a = Arrays.binarySearch(alpha, letter);
System.out.print(alpha[a+3]);
}
}
System.out.print("\n");
} |
Partager