Skip to content

Instantly share code, notes, and snippets.

@IamKien
Created September 14, 2012 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IamKien/3719507 to your computer and use it in GitHub Desktop.
Save IamKien/3719507 to your computer and use it in GitHub Desktop.
Social Securities Number
//Objective: This program will take the input of the social security number and fix it or declare an error.
import java.util.*;
public class SocialSecurities
{
public static void main (String args [])
{
String ssnum;
Scanner sc = new Scanner(System.in);
while(true)
{
System.out.print("Please enter your Social Security number, type quit or stop to exit ");
ssnum = sc.nextLine();
if (ssnum.equalsIgnoreCase("quit") || ssnum.equalsIgnoreCase("stop")) break;
int ss;
char c;
for(int i = 0; i < ssnum.length();i++ )
{
c = ssnum.charAt(i);
if (! Character.isDigit(c))
{
System.err.println(""+c + "is not a digit");
}
{
ss = Integer.parseInt(ssnum);
if (ss == 11);
{
System.err.println ("Invalid amount of numbers");
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment