How do i prevent number duplication in this program. Basically so that i don't have to enter the same number again
here's the code:
import java.awt.*;
import hsa.Console;
public class BubbleSort_Strings
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
c.println ("\t\t\tIPOD Downloads\n\n");
c.print ("Enter the number of songs: ");
int max = c.readInt ();
c.println ();
String song[] = new String [max];
String tempSong;
for (int i = 0 ; i <= max - 1 ; i = i + 1)
{
c.print ("Enter the name of song " + (i + 1) + ": ");
song = c.readLine ();
c.println ();
} //end for i
//sort the song names in the array alphabetically
for (int x = 0 ; x < max - 1 ; x++)
{
for (int y = x + 1 ; y < max ; y++)
{
if (song [x].compareTo (song [y]) > 0)
{
tempSong = song [x];
song [x] = song [y];
song [y] = tempSong;
} //end if
} //end for y
} //end for x
c.println ("Your songs have now been sorted:");
c.println ();
for (int z = 0 ; z <= max - 1 ; z = z + 1)
{
c.println (song [z]);
} //end for z
} // main method
} // BubbleSort_Strings class