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

 

prefixNameSuffix


Given a prefix, name, and suffix, return a combined string that starts with the prefix, has the name in the middle separated by a space on each side, and ends with the suffix; however, if the suffix does not start with “of ”, then insert “of ” between the suffix and the name. If the prefix starts with “of “, then remove the “of “. The string returned should never start or end with " " or "of".

Note: Because of how white space is handled in HTML, you may get cases that appear to match perfectly as far as you can see, but are actually incorrect due to having an extra space. If a case is marked wrong, but looks the same, check your code carefully to see where the extra space could have come from.


prefixNameSuffix("Ultimate", "Axe", "Slicing") → "Ultimate Axe of Slicing"
prefixNameSuffix("Singing", "Sword", "of Dissonance") → "Singing Sword of Dissonance"
prefixNameSuffix("of Dancing", "Boots", "Rhythm") → "Dancing Boots of Rhythm"

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

public String prefixNameSuffix(String prefix, String name, String suffix) { }

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

Copyright Nick Parlante 2017 - privacy