我一直在尝试制作一个允许我加密用户名和密码并打印结果的程序。我可以让它工作,但我想将循环中出现的字符排序为一个字符串,以便于管理。有什么建议吗?
System.out.println("\nYour encrypted username is " );
for(char c : namech)
{
int temp = (int)c;
int namecode = 0;
//makes the characters w,x,y,z loops back to the start of the alphabet
if(temp<=90 & temp>=65)
{
namecode = temp+4;
if(namecode == 91)
{
namecode = 65;
}
else if(namecode == 92)
{
namecode = 66;
}
else if(namecode == 93)
{
namecode = 67;
}
else if(namecode == 94)
{
namecode = 68;
}
int i = namecode;
char d = (char)i;
System.out.print(d);
}