I'm currently having an issue with this function. I'm getting an error for the numSongs in getSongsArray(numSongs); saying that I need to throw an exception (unreported exception Exception; must be caught or declare to be thrown). Below is the instructions and the code I currently have. I'm just a girl whose been struggling on this for about 3 hours now and at this point I'm desperate.
Instructions: Write a method called getSongsArray that takes an integer parameter (numSongs), returns an array of Strings, and is declared to throw an Exception. If the parameter passed is a negative value, throw an Exception. Otherwise, loop numSongs times prompting the user to enter another name each pass through the loop. Return this array of names.
Call getSongsArray passing the size of the array (any integer) that you want returned
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
System.out.println("How many songs would you like to enter?");
int numSongs = scnr.nextInt();
getSongsArray(numSongs);
} //end main
public static int getSongsArray(int numSongs) throws Exception
{
if (numSongs <= 0)
{
throw new Exception("Invalid Number");
}
} //end getSongsArray