Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

tag challenge

Posted on 2014-11-10
3
Medium Priority
?
143 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

722 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