Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tag challenge

Posted on 2014-11-10
3
Medium Priority
?
152 Views
Last Modified: 2014-11-11
Hi,

I am trying below example

http://codingbat.com/prob/p147483


i put code as below
public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"<"+tag+">";
}

Open in new window


I got output as below
Expected      Run            
makeTags("i", "Yay") → "<i>Yay</i>"      "<i>Yay<i>"      X         
makeTags("i", "Hello") → "<i>Hello</i>"      "<i>Hello<i>"      X         
makeTags("cite", "Yay") → "<cite>Yay</cite>"      "<cite>Yay<cite>"      X         
makeTags("address", "here") → "<address>here</address>"      "<address>here<address>"      X         
makeTags("body", "Heart") → "<body>Heart</body>"      "<body>Heart<body>"      X         
makeTags("i", "i") → "<i>i</i>"      "<i>i<i>"      X         
makeTags("i", "") → "<i></i>"      "<i><i>"      X         
other tests


How do i improve and fix my code.
0
Comment
Question by:gudii9
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 40433990
You are missing a "/" character in your end tag
0
 
LVL 7

Author Comment

by:gudii9
ID: 40434878
public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"<"+tag+"/>";
}

Open in new window


I tried as above still test cases are failing. Please advise on what i am doing wrong.
Expected      Run            
makeTags("i", "Yay") → "<i>Yay</i>"      "<i>Yay<i/>"      X         
makeTags("i", "Hello") → "<i>Hello</i>"      "<i>Hello<i/>"      X         
makeTags("cite", "Yay") → "<cite>Yay</cite>"      "<cite>Yay<cite/>"      X         
makeTags("address", "here") → "<address>here</address>"      "<address>here<address/>"      X         
makeTags("body", "Heart") → "<body>Heart</body>"      "<body>Heart<body/>"      X         
makeTags("i", "i") → "<i>i</i>"      "<i>i<i/>"      X         
makeTags("i", "") → "<i></i>"      "<i><i/>"      X         
other tests
X
0
 
LVL 7

Author Comment

by:gudii9
ID: 40435028
public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"</"+tag+">";
}

Open in new window


above worked fine
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question