Solved

tag challenge

Posted on 2014-11-10
3
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

617 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