Question: Java I need to display a six family members names and then store the first name of each member in an array. I need to

Java

I need to display a six family members names and then store the first name of each member in an array. I need to use a loop to output each name alongside the index number of each name. Then i need to use a loop to move backwards through the array and output the name in reverse order and need to output the size of the array using the length field.

example.

here are the names you input.

1) jake

2) jason

3) smith

4) cindy

5) sara

6) amy

Here is your name in reverse order

1) amy

2) sara

3) cindy

4) smith

5) jason

6) jake

// NOW I DID NOT HAVE TO ASK THE USER FOR THE NAMES BUT I AM HOPING TO GET EXTRA CREDIT FOR ADDING IT THE PROGRAM.

// HERE IS WHAT I HAVE SO FAR.

Scanner scanner = new Scanner (System.in); System.out.print("How many family members do you have? "); int num = scanner.nextInt(); int a[] = new int[num]; // FROM THIS POINT I WANT TO BEABLE TO TYPE IN THE NAMES AND NOT INTS System.out.print("What are the names of your family members? "); for(int i = 0; i < num; i++) { a[i] = scanner.nextInt(); } // WANT TO DISPLAY THEM IN REVERSE ORDER WITH COMMOM OR SPACE BETWEEN // EACH NAME. System.out.println("Here is a list of your family members name in reverse" + " order! "); for (int i=a.length - 1; i >= 0; i--) { System.out.print(a[i]); }

// THANKS FOR ALL THE HELP

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!