Create 3 arrays that will hold 5 employee information:
Name
Address
For example: empName[0], empAddress[0], empEmail[0] should belong to the same employee.
-----------------------------------------------------------------------------------------------------------------------------------------------------
We will output the employee's information by using int variable as index.
The user will select what index will be printed on the console so you need to use the java.util.scanner.
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = -1;
while (n < 0) {
System.out.println("Input n. n should be >= 0 and < 5");
n = scanner.nextInt();
}
String [] empName = new String[]{"Tom Holland", "Lisa Simpson", "John Legend", "Jack Harrison", "Simon Cowell"};
String [] empAddress = new String[]{"94 Tower Drive Gallatin, TN 37066", "158 Roosevelt Rd.Dekalb, IL 60115",
"7665 Rockledge St.Ridgewood, NJ 07450", "409 Schoolhouse St.Loxahatchee, FL 33470", "811 Brickell St.Woonsocket, RI 02895"};
String [] empEmail = new String[]{"tom.holland@corporation.email", "lisa.simpson@corporation.email",
"john.legend@corporation.email", "jack.harrison@corporation.email", "simon.cowell@corporation.email"};
System.out.println(empName[n]);
System.out.println(empAddress[n]);
System.out.println(empEmail[n]);
}
Comments
Leave a comment