だから、言葉遊びのプロジェクトがあり、いくつかの文字を暗号化する必要があります。私は立ち往生しているところで、それを実行して暗号化のために 1 を入力すると、それほど多くの文字がシフトしません。作品をもう一度印刷するだけです。「こんにちは」と言うと、1文字が印刷されて「ifmmp」と表示される場所を修正するために何ができるか疑問に思っています ありがとう!
import java.util.Scanner;
public class WordPlayTester{
public static void main(String [] args){
String word, reverse="";
String original;
int key= 0;
String Menu= "1-Encrypt \n2-Decrypt \n3-Is Palindrome \n0-Quit \n-Select an option-";
Scanner in = new Scanner(System.in);
System.out.println("-Type any word-");
word = in.nextLine();
System.out.println(Menu);
int choice=in.nextInt();
if(choice==1)
{
System.out.println("Insert a Key number");
int select= in.nextInt();
for (int i=0; i < word.length(); i++) {
char c = word.charAt(i);
if (c >= 'A' && c <= 'Z') {
c = (char)(c - 64);
int n = c+1;
n = n % 26;
if (n < 0) {
n = n + 26;
}
c = (char)(n + 65);
}
System.out.println(c);
}
}
else if(choice==3)
{
int length = word.length();
for ( int i = length - 1 ; i >= 0 ; i-- )
reverse = reverse + word.charAt(i);
if (word.equals(reverse))
System.out.println("Your word is a palindrome.");
else
System.out.println("Your word is not a palindrome.");
}
else if(choice==0)
{
System.exit(0);
}
else
{
System.out.println(Menu);
}
}
}