Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function, addTag(s, tag) that takes a string, s, and another string, tag

ID: 3723670 • Letter: W

Question

Write a function, addTag(s, tag) that takes a string, s, and another string, tag, and returns a new string the surrounds the string s with an html style tag. An HTML tag consists of a left angle bracket, the tag, and the right angle bracket. HTML tags come in pairs and the second one has a "/" before the tag. Study the following examples to see how it should work: addTags("Hello", "pre") should return the string '<pre>Hello</pre>' addTags("Some more text", "bold") should return the string '<bold>Some more text</bold>'

Explanation / Answer

public String addTag(String s,String tag) {

String output = "<" + tag + ">" + s + "</" + tag +">";

return output;}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote