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

 

orion.a.smith@gmail.com apcsa-loops > apcsaLoopsConcatInclusiveAscendingWithSpaces
prev  |  next  |  chance

Given two numbers a and b, build a String that contains every number from a to b, inclusive. But now, in between each pair of element, add a space " " character. Precondition: a < b for all inputs.


HINT: use an if statement to determine when you should add a space.

apcsaLoopsConcatInclusiveAscendingWithSpaces(1, 2) → "1 2"
apcsaLoopsConcatInclusiveAscendingWithSpaces(3, 5) → "3 4 5"
apcsaLoopsConcatInclusiveAscendingWithSpaces(1, 8) → "1 2 3 4 5 6 7 8"

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

public String apcsaLoopsConcatInclusiveAscendingWithSpaces(int a, int b) { }

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