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

 

cynthia.gallatin@pisd.edu lab5a > socialSecuritySum
prev  |  next  |  chance

A Social Security number consists of a 3-digit number, a dash, a 2-digit number, a dash, and a 4-digit number. Chop up a Social Security number, add up the three numeric pieces, and return the total. If the SSN is not in the correct format, it is invalid! If it is invalid, return -1.


socialSecuritySum("456-56-2341") → 2853
socialSecuritySum("1-1-1") → -1
socialSecuritySum("10-122") → -1

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

public int socialSecuritySum(String ssn){ }

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: 150 Post-solution available

Copyright Nick Parlante 2017 - privacy