Solved

tag challenge

Posted on 2014-11-10
3
116 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 84

Accepted Solution

by:
ozo earned 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now