ユーザーに文字の入力を求める、常にtrueのwhileループがあります。文字が入力されると、switchステートメントで検索され、さらに入力が要求されるswitchステートメントからコードのブロックが実行されます。コードの出力は、コードの一部でユーザーの入力として登録されているようです。これが私のコードの簡単なサンプルです:
while (true) {
System.out.print("Enter a letter :: ");
selection = keyboard.nextLine();
selection = selection.toUpperCase();
switch (selection) {
case "A":
A = null;
A = new Matrix();
System.out.println("Default matrix A initialized.");
break;
case "C":
System.out.print("Enter the number of rows (rows > 0) :: ");
rows = keyboard.nextInt();
System.out
.print("Enter the number of columns (colums > 0) :: ");
cols = keyboard.nextInt();
System.out
.print("Enter the initial value for each element :: ");
initialValue = keyboard.nextInt();
C = null;
C = new Matrix(rows, cols, initialValue);
System.out.println("Matrix C initialized.");
break;
}
}