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

 

changeMiddle


String changeMiddle(String str): Returns a copy of the original string, but modified as follows: If the string has an odd number of characters, replace the middle letter with 3 capital A's. If the string has an even number of characters, replace the middle two letters with three capital Z's. The input string can be of any length, including 0. RUBRIC: It is not enough to just solve the problem. Make sure you use PROPER INDENTATION. You MUST use CURLY BRACKETS for all loops and if/else statements. Also, the more EFFICIENT your solution, the higher your grade. If you have extraneous (superfluous / unnecessary) code, deductions will be taken.


changeMiddle("Jack") → "JZZZk"
changeMiddle("Queenie") → "QueAAAnie"
changeMiddle("Romeo and Juliet") → "Romeo aZZZ Juliet"

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

public String changeMiddle(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: 20

Copyright Nick Parlante 2017 - privacy