Answer to Question #310800 in Java | JSP | JSF for Michael Parenas

Question #310800

Create 3 arrays that will hold 5 employee information:



Name



Address



Email



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.

1
Expert's answer
2022-03-13T15:11:00-0400
import java.util.Scanner;


public class App {


	/** Main Method */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in); // Create a Scanner


		String empName[] = new String[5];
		String empAddress[] = new String[5];
		String empEmail[] = new String[5];


		for (int i = 0; i < 5; i++) {
			System.out.print("Name: ");
			empName[i] = keyBoard.nextLine();
			System.out.print("Address: ");
			empAddress[i] = keyBoard.nextLine();
			System.out.print("Email: ");
			empEmail[i] = keyBoard.nextLine();
		}


		System.out.print("Select what index will be printed [0-4]: ");
		int index = keyBoard.nextInt();
		System.out.println("Name: " + empName[index]);
		System.out.println("Address: " + empAddress[index]);
		System.out.println("Email: " + empEmail[index]);


		keyBoard.close();
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS