In the following program skeleton, replace
songs, searchText, foundIndex,and
count). The resulting program should prompt the user for a search string and then display the number of occurrences of the search string in a given list of songs. Study the sample session.
import java.util.Scanner;public class CountSubstringOccurrences{ public static void main(String[] args) { scanner stdIn = new Scanner(System.in) ; string songs = “1. Green Day - American Idiot\n” + “2. Jesus Jones - Right Here, Right Now\n” + “3. Indigo Girls - Closer to Fine\n” + '' “4. Peter Tosh - Equal Rights\n”; String searchText; // text that is searched for int foundIndex; // position of where text is found int count = 0; // number of occurrences of search text system.out.print(“Enter search text: “); searchText = stdIn.nextLine();
System.out.println(“Number of occurrences of \"" + searchText + "\": " + count); } // end main} // end class CountSubstringOccurrences
Sample session:
Enter search text: RightNumber of occurrences of "Right": 3
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.