Banana fee fi fo fana song


Asked by maham237 @ in Computers And Technology viewed by 792 People


Modify songVerse to play "The Name Game" (see OxfordDictionaries), by replacing "(Name)" with userName but without the first letter. Ex: If userName = "Kaitlin" and songVerse = "Banana-fana fo-f(Name)!", the program prints: Banana-fana fo-faitlin! Ex: If userName = "Kaitlin" and songVerse = "Fee fi mo-m(Name)", the program prints: Fee fi mo-maitlin Note: You may assume songVerse will always contain the substring "(Name)".

Answered by maham237 @



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.

Similar Questions

Overcoming fixed mindset: a step-by-step guide to cultivating a growth mindset

Asked by wiki @ in Health viewed by 1192 persons

Which of the following would best complete this list?

Asked by wiki @ in Social Studies viewed by 682 persons

What had the king decided to do before he saw the spider

Asked by vanshika149 @ in English viewed by 1059 persons

Describe the karez in your own words

Asked by rajesh064 @ in English viewed by 1213 persons

What is 8 + (x + 5)?

Asked by jaylord7 @ in Mathematics viewed by 1020 persons

What is the topic of the info grapher

Asked by jesus643 @ in History viewed by 1307 persons

Elephant kills 11 in nepal , woman rescued from a friendly dolphine

Asked by kavin044 @ in English viewed by 1187 persons

(-3,0);slope =2/3

Asked by timothy2 @ in Biology viewed by 1459 persons

Which is an example of situational irony in "wherefore art thou romeo?”

Asked by noah5213 @ in English viewed by 1467 persons

How to enhance knowledge regarding environmental factors through capsim?

Asked by wiki @ in Business viewed by 1647 persons

Most viewed questions in Computers And Technology


Codehs python answer key

Asked by maham237 @ in Computers And Technology viewed by 2077 persons


3.4 6 t shirt shop codehs answers

Asked by maham237 @ in Computers And Technology viewed by 1846 persons



Security infrastructure design document

Asked by wiki @ in Computers And Technology viewed by 1797 persons


Codehs python answers

Asked by maham237 @ in Computers And Technology viewed by 1162 persons


In the business world people are often measured by their

Asked by maham237 @ in Computers And Technology viewed by 1096 persons




Banana fee fi fo fana song

Asked by maham237 @ in Computers And Technology viewed by 792 persons


List 10 www standards that the w3c develops and maintains

Asked by maham237 @ in Computers And Technology viewed by 778 persons


Open the excel workbook revenue xls from the default directory

Asked by maham237 @ in Computers And Technology viewed by 742 persons



In order to protect your computer from the newest viruses

Asked by maham237 @ in Computers And Technology viewed by 737 persons