我无法找到如何修改扫描仪中的字符。代码应该像'9'这样的数字,并找到它在图表中的位置,将它从'o'转换为'x'。我的代码:如何用扫描仪修改字符串数组?
import java.util.Scanner;
public class a10
{
public static void main (String[] args)
{
Scanner input = new Scanner (System.in);
System.out.println("1 for first class \n2 for economy \n3 to view seating chart \n0 to exit");
//error message: Your choice must be a number between 0 and 3.
int menu = input.nextInt();
if (menu == 1) {
System.out.println("Which seat would you like (1-9): ");
int selection = input.nextInt();
//Seats in first class must be between 1 and 9.");
}
else if (menu == 2) {
System.out.println("Which seat would you like (10-30): ");
int selection = input.nextInt();
//Seats in economy class must be between 10 and 30.");
}
else if (menu == 3) {
//public static boolean[] seatChart (boolean seatNumber)
char[] seatNumber;
char[][] grid = new char[][]{{'o','o','o'},{'o','o','o'},{'o','o','o'}};
}
}
}
应该如何看待
Front
x x x
x x o
o o o
x x x
x x x
x x x
x o o
o o o
x o x
o o o
Back
*“如何进行?” *你可以对正是你所面临的问题是有点更彻底? – Gendarme