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

 

abraskin@mbusd.org problemset08 > strToInt
prev  |  next  |  chance

Given a String return an integer value. Ignore characters that are not digits unless there is a negative sign before the first digit in which case the integer value should be negative. The first non-digit character found after a number starts ends the number so "abc123abc", "123", "123abc", and "abc123.5" are all the integer value 123.


If no number is found return 0.

strToInt("abc123abc") → 123
strToInt("123") → 123
strToInt("123abc") → 123

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

public int strToInt(String s) { }

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: 300

Copyright Nick Parlante 2017 - privacy