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

 

Logic-1 > sumLimit
prev  |  next  |  chance

Given 2 non-negative ints, a and b, return their sum, so long as the sum has the same number of digits as a. If the sum has more digits than a, just return a without b. (Note: one way to compute the number of digits of a non-negative int n is to convert it to a string with String.valueOf(n) and then check the length of the string.)


sumLimit(2, 3) → 5
sumLimit(8, 3) → 8
sumLimit(8, 1) → 9

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

public int sumLimit(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: 169

Copyright Nick Parlante 2017 - privacy