I need to get the same output as this program using an if statement. What the program does is that, it initializes values for a 2d array named employeeInfo. Then it prompts the user to input an idNumber. The condition must be, if idNumber is equal to 1(which is the value of employeeInfo[0][0]), then it will print the values of employeeInfo[0][1] and employeeInfo[0][2]. Same for the others. If idNumber is 2, then it will print Eunice 50,000, and if idNumber is 3, it will print Diane 70,000. I really hope you can help me. I'm a beginner in java. Godbless
import javax.swing.JOptionPane;
public class Assignment2{
public static void main(String[] args){
String[][] employeeInfo ={{"1","Mira","100,000"},
{"2","Eunice","50,000"},
{"3","Diane","70,000"}};
String idNumber="";
idNumber=JOptionPane.showInputDialog("Please enter employee idNumber:");
switch(idNumber)
{
case "1":
for(int i=0;i<employeeInfo.length;i++)
{
for(int j=1;j<employeeInfo[i].length;j++)
{
System.out.println(employeeInfo[i][j]);
}
break;
}
break;
case "2":
for(int i=1;i<employeeInfo.length;i++)
{
for(int j=1;j<employeeInfo[i].length;j++)
{
System.out.println(employeeInfo[i][j]);
}
break;
}
break;
case "3":
for(int i=2;i<employeeInfo.length;i++)
{
for(int j=1;j<employeeInfo[i].length;j++)
{
System.out.println(employeeInfo[i][j]);
}
}
break;
default:
System.out.println("You entered an invalid idNumber!");
break;
}
}
}