我無法找到如何修改掃描儀中的字符。代碼應該像'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