In the following program skeleton, replace the < insert code here> line with the appropriate code. The resulting program should display the initial list of songs, prompt the user for a string of text to be replaced and then prompt for new text to replace it. After making the replacement, it should display the updated list of songs. import java.util.Scanner; public class UpdateSongs { public static void main ( String [] args) { Scanner stdIn = new Scanner(System.in); String songs = “ 1. Welcome to Your Life – Grouplove\n” + “ 2. Sedona – Houndmouth\n” + “3. Imagine – John Lennon\n” + “4. Bohemian Rhapsody –Queen\n”; String oldText, newText; < insert code here> } } Sample Session: 1. Welcome to Your Life – Grouplove” 2. Sedona – Houndmouth 3. Imagine – John Lennon 4. Bohemian Rhapsody –Queen Enter text to replace: Lennon Enter new text: Dean 1. Welcome to Your Life – Grouplove” 2. Sedona – Houndmouth 3. Imagine – John Dean 4. Bohemian Rhapsody –Queen
In the following
appropriate code. The resulting program should display the initial list of songs,
prompt the user for a string of text to be replaced and then prompt for new text to
replace it. After making the replacement, it should display the updated list of songs.
import java.util.Scanner;
public class UpdateSongs
{
public static void main ( String [] args)
{
Scanner stdIn = new Scanner(System.in);
String songs =
“ 1. Welcome to Your Life – Grouplove\n” +
“ 2. Sedona – Houndmouth\n” +
“3. Imagine – John Lennon\n” +
“4. Bohemian Rhapsody –Queen\n”;
String oldText, newText;
< insert code here>
}
}
Sample Session:
1. Welcome to Your Life – Grouplove”
2. Sedona – Houndmouth
3. Imagine – John Lennon
4. Bohemian Rhapsody –Queen
Enter text to replace: Lennon
Enter new text: Dean
1. Welcome to Your Life – Grouplove”
2. Sedona – Houndmouth
3. Imagine – John Dean
4. Bohemian Rhapsody –Queen
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images