id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > nov3_2017_APSLHL_stringDash
prev  |  next  |  chance

Write a method that takes a string input parameter and returns a new string based on the input parameter but with dashes inserted between each consecutive characters in such a way that each new insertion of dashes has one more dash than the previous one. For example, the string "this" becomes "t-h--i---s". Do NOT insert any dashes after the last character. If the string only has one character or is empty, simply return the original string.


nov3_2017_APSLHL_stringDash("this") → "t-h--i---s"
nov3_2017_APSLHL_stringDash("A") → "A"
nov3_2017_APSLHL_stringDash("") → ""

...Save, Compile, Run (ctrl-enter)

public String nov3_2017_APSLHL_stringDash(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy