入力が配列の要素と一致する行全体を印刷する方法は? 私のコードのどこが間違っていたのか見てください... :(
package scanner;
import java.util.Arrays;
import java.util.Scanner;
public class EmployeeInformation {
static Scanner sc = new Scanner(System.in);
static String info[][] = {{"09-001", "Ja Gb", "100", "10", },
{"09-002", "Justine", "200", "20", ""},
{"09-003", "Ja Ja", "150", "15", ""}};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print(" - MENU -\n");
System.out.print("A. Search Record\nB. Payroll Summary\n------------------\nEnter choice: ");
String choice = null;
choice = sc.nextLine();
if (choice.equalsIgnoreCase("a")) {
System.out.print("Enter Employee #: ");
String EmpNum = sc.nextLine();
SearchRecord(EmpNum);
}
else {
PayrollSummary();
}
}
private static void SearchRecord(String employeeNumber) {
// TODO Auto-generated method stub
String row[] = new String[3];
int i = 0;
while(i <= info.length) {
int j = 0;
while(j <= info.length) {
if(employeeNumber.equals(info[i][j])) {
for (int a = 0; a <= row.length; a++) {
row[a] = info[i][j];
System.out.print(row[a]);
a++;
}
}
else {
System.out.print("Invalid employee number.");
System.exit(0);
}
j++;
}
i++;
}
}
private static void PayrollSummary() {
System.out.println("Employee #:\tEmployee Name\tRate per Hour\tTotal Hours Worked\tGross Pay");
int r = 0;
while ( r <= info.length - 1) {
int c = 0;
while ( c <= info.length ) {
System.out.print(info[r][c] + "\t\t");
if (c == 3) {
System.out.print("\n");
}
c++;
}
r++;
}
//for (int a = 0; a <= info.length -1; a++) {
// Integer.parseInt(info[a][4]) = Integer.parseInt((info[a][3]) * (info[a][4]));
//}
}
}
入力が要素と一致する場合はどうすればよいですか? ヒントをください