Solved

word inside a tag challenge

Posted on 2014-11-10
2
172 Views
Last Modified: 2014-11-11
Hi,

I am trying below challenge
http://codingbat.com/prob/p184030

I wrote code as below

public String makeOutWord(String out, String word) {
  return out+word+out;
}

Open in new window



My test cases are failing

How to fix and improve my code. Please advise
0
Comment
Question by:gudii9
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40433992
Note: use str.substring(i, j) to extract the String starting at index i and going up to but not including index j.
0
 
LVL 7

Author Comment

by:gudii9
ID: 40434895
public String makeOutWord(String out, String word) {
  return out.substring(0,2)+word+out.substring(2,4);
}

Open in new window


i tried as below works good
Expected      Run            
makeOutWord("<<>>", "Yay") → "<<Yay>>"      "<<Yay>>"      OK         
makeOutWord("<<>>", "WooHoo") → "<<WooHoo>>"      "<<WooHoo>>"      OK         
makeOutWord("[[]]", "word") → "[[word]]"      "[[word]]"      OK         
makeOutWord("HHoo", "Hello") → "HHHellooo"      "HHHellooo"      OK         
makeOutWord("abyz", "YAY") → "abYAYyz"      "abYAYyz"      OK         
other tests
OK
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now