Im stuck on my loop program, I have to create a loop program for arrays which only stops if a user inputs quit or the user has input 1000 entries, the program then has to sort the arrays in order of composer. I've tried so many different kinds of algorithms that my mind has gone back to basics
import javax.swing.*;
class ClassicMusic
{
public static void main (String [] args)
{
String composer[] = new String[999];
String piece[] = new String[999];
Input(composer,piece);
System.exit(0);
}
public static void Input(String [] composer, String [] piece)
{
int i = 0;
composer [i] = "";
while(!composer[i].equals("q"))
{
//for(int i = 0; i<=999; i++)
composer [i] = JOptionPane.showInputDialog("input composer");
piece [i] = JOptionPane.showInputDialog("input piece");
i = i+1;
}
SortA(composer,piece);
}
public static void SortA(String []composer, String [] piece)
{
for (int j = 0; j<=999; j++)
{
if(composer[j].equals(j++))
{
System.out.println(composer[j]);
System.out.println(piece[j]);
}
}
}
}
thank you.