A quickly brief history of my Homework assignment.
Using the code examples that you created, sort the following items: Rocket J. Squirrel, Bullwinkle J. Moose, Boris Badenov, Natasha Fatale, Fearless Leader, Mr. Big, Cloyd, Gidney, Metal-Munching Moon Mice, Capt. Peter "Wrongway" Peachfuzz, Edgar, and Chauncy
Your program should perform the following tasks.
1. Read the data in from the keyboard into the array interactively.
2. Print the array.
3. Sort the array in ascending order using the bubble sort;
4. Print the array;
5. Sort the array in descending order using the bubble sort;
6. Print the array.
Further specification:
You must use a separate method for each task.
There must be a method for loading the data into the array.
There must be one and ONLY one method for printing the contents of the array.
There must be a method for sorting the array in ascending order.
There must be a method for sorting the array in descending order.
If you do not use the bubble sort in the methods which sort the data, do not bother handing your code in to me.
The list of names is long. Save yourself some aggravation with these two suggestions:
1. Use the nextLine() method to read the String data from the keyboard into the array.
2. Do NOT enter all the data each time you test. Start by entering only one character instead of
each full name. Enter all of the entire names when you are sure all of your sorting and printing
algorithms are running correctly.
import java.util.*; public class lab7 { public static void main (String[] args) { String x = " "; String x1 = ""; x1 = storedList(x); printArray(x1); } public static String storedList( String stored) { Scanner scan = new Scanner(System.in); String[] list = new String[12]; System.out.println( "Hello user, I will sort your list in asscending and descending order? "); System.out.println( "Please enter your string." ); for( int i = 0; i <=11; i++) { list[i] = scan.nextLine(); } return stored; } public static void printArray(String[] displayed) { String[] list = new String[12]; for (int i = 0; i <= 11; i++) { System.out.print( list[i] + " " ); } } }
What I'm having issues is passing arguments into each method. I was able to figure out how to make one method to accept my array. But I'm having trouble creating a method to print the array. I keep receiving this compiler error. Please refer to screen shot. PLEASE help!
complier_errro.jpg
Thanks Again!