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

 

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

Write a method that accepts a string 'num' which represents a binary number. That string will ONLY contain 1's and 0's. Return how many 1's appear in the string. Please note that the string 'num' can be of any length.


test2021_01_15_APP1SLHL_countBinaryOnes("10001000101") → 4
test2021_01_15_APP1SLHL_countBinaryOnes("1") → 1
test2021_01_15_APP1SLHL_countBinaryOnes("0") → 0

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

public int test2021_01_15_APP1SLHL_countBinaryOnes(String 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: 230

Copyright Nick Parlante 2017 - privacy