Question: Module 7 is entitled: Single-Dimensional Arrays. Consider the code that is in page 259, Listing 7.3: TestPassArray.java file. Consider line 4: int [] a={1,2}; Your

Module 7 is entitled: "Single-Dimensional Arrays".

Consider the code that is in page 259, Listing 7.3: TestPassArray.java file.

Consider line 4: int [] a={1,2};

Your task is to:

1- Replace the int a array into a String a array. Also make sure the "first element" of the a array is your actual first name and the "second element" of the a array is your last name. (10 points).

To get the two methods swap() at line 22 and swapFirstTwoInArray() at line 29 to work make sure you remove the int and replace it with a String.

2- This time we want to swap the two strings if the first string is smaller than second string. Meaning: "George" < "Meghabghab" because 'G' is < 'M'. Otherwise we do not swap the elements of the String array.

3- In order to 1- and 2- to work, first take out the code with the old code and make sure you replace it with the requirements of 1- and 2-.

Make sure that the two methods swap() and swapFirstTwoInArray() work and compile correctly. (20 points)

If your code does not produce the correct result I will take points away.

Save your code and submit the java file under your: lastname_firstname_TestPassArray.java

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!