我希望整数存储在数组中,然后一旦用户输入0,while循环将停止并以字符串格式打印数组的内容。
我尝试了这个地区的东西,但老实说我不理解他们。
public static void apples() {
Scanner input = new Scanner(System.in);
System.out.println("Enter your integer: ");
int number = input.nextInt();
int[] array = {};
while(number != 0) {
if(number == 1){
System.out.println("0");
}
else if (number == 3) {
System.out.println("f");
}
else if (number == 5) {
System.out.println("-l");
}
else if (number == 7) {
System.out.println("V");
}
else if (number == 9) {
System.out.println("-/");
}
else if (number == 11) {
System.out.println("()");
}
else if (number == 13) {
System.out.println("()");
}
else if (number == 15) {
System.out.println("^");
}
else if (number == 17) {
System.out.println("E");
}
else if (number == 19) {
System.out.println("=");
}
else if (number == 21) {
System.out.println("x");
}
else if (number == 23) {
System.out.println("y");
}
System.out.println("int: " + number);
}
};
我的预期结果是输入135,输出为0f-l
倚天杖
慕后森
吃鸡游戏
相关分类