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

 

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

Write a method that returns 'str' surrounded by 'num' number of parenthesis (round brackets). For example, if 'str' is "Yoda" and 'num' is 3, you would return "(((Yoda)))". Look at the test data for more examples. As a precondition you may assume that 'num' is non-negative. There are many possible solutions to this problem. It can be done recursively, or using two loops, or even using just one loop!


test2020_12_10_APP1SLHL_brackets("^", 12) → "((((((((((((^))))))))))))"
test2020_12_10_APP1SLHL_brackets("*", 1) → "(*)"
test2020_12_10_APP1SLHL_brackets("What should have been the LEAST popular movie in 2020?", 0) → "What should have been the LEAST popular movie in 2020?"

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

public String test2020_12_10_APP1SLHL_brackets(String str, int num) { }

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: 220

Copyright Nick Parlante 2017 - privacy