如何打印输入与数组元素匹配的整行?请看看我的代码我哪里出错了...... :(
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]));
//}
}
}
当输入匹配一个元素时我应该怎么做?请给我一个提示