Problem

In the following program skeleton, replace  with your own code. Hint: Use the variables th...

In the following program skeleton, replace  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);    ptring 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 for   int songIndex; // position of where song number is found   int eolIndex; // position of end of line character   String song; // the specified line    System.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

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT