In the following program skeleton, replace <Insert code here.> with your own code. Hint: Use the variables that are already declared for you (songs, songNum, songIndex, eolIndex, and song). The resulting program should prompt the user for a song number and then extract the song number plus the rest of that string’s line from a given list of songs. Study the sample session. You may assume that the user enters a valid song number (no need for input validation).
import java.util.Scanner;public class ExtractLine{public static void main(String[] args){Scanner stdIn = new Scanner(System.in);String songs ="1. Bow Wow - Fresh Azimiz\n" +"2. Weezer - Beverly Hills\n" +"3. Dave Matthews Band - Crash Into Me\n" +"4. Sheryl Crow - Leaving Las Vegas\n";String songNum; // song number that is searched forint songIndex; // position of where song number is foundint eolIndex; // position of end of line characterString song; // the specified lineSystem.out.print("Enter song number: ");songNum = stdIn.nextLine();System.out.println(song);} // end main} // end class ExtractLine Sample session:
Enter song number: 33. Dave Matthews Band - Crash Into Me
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.