Answer:
Following are the modification of the code:
import java.util.*;//import package for user input
public class NameSong //defining NameSong
{
public static void main (String [] args) //defining the main method
{
String userName,songVerse;//defining string variable
Scanner obxc = new Scanner(System.in);//creating Scanner class object
userName = obxc.nextLine();//input string value
songVerse = obxc.nextLine();//input string value
userName = userName.substring(1); // Removes first char from userName
songVerse = songVerse.replace("(Name)",userName);//remove and hold value in songVerse
System.out.println(songVerse);//print value
}
}
Output:
please find the attachment.
Explanation:
Description of the code:
- In the above code, a two-string variable "userName and songVerse" is declared, in which we input value by creating scanner class object that is "obxc".
- In the next step, two inbuilt string methods "substring and replace" are used, in which the first method is used to remove the first character from the name, and the second method replaces the value from the second input.
- At the last step, the print methods have used that prints its replaced value.