Solved

word inside a tag challenge

Posted on 2014-11-10
2
180 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
[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 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

739 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