175k views
1 vote
Modify songVerse to play "The Name Game" (OxfordDictionaries), by replacing "(Name)" with userName but without the first letter. Ex: If userName

1 Answer

4 votes

Answer:

The Java code for the problem is given below.

Your solution goes here is replaced/modified by the statement in bold font below

Step-by-step explanation:

import java.util.Scanner;

public class NameSong {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

String userName;

String songVerse;

userName = scnr.nextLine();

userName = userName.substring(1);

songVerse = scnr.nextLine();

songVerse = songVerse.replace("(Name)", userName);

System.out.println(songVerse);

}

}

User Comendeiro
by
4.1k points