Answer to Question #310626 in Java | JSP | JSF for Billy Jean

Question #310626

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-13T01:11:36-0500
    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]);
    }

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