1import java.util.Scanner;
2
3public class ProgrammingEx4_21 {
4 public static void main(String[] args) {
5 Scanner input = new Scanner(System.in);
6
7 System.out.print("Enter a SSN:");
8 String s = input.nextLine();
9
10 for (int i = 0; i < s.length(); i++) {
11 if ((i == 3 || i == 6) && s.charAt(i) == '-') {
12 continue;
13 }
14 if (!Character.isDigit(s.charAt(i))) {
15 System.out.println(s + " is an invalid social security number");
16 System.exit(0);
17 }
18 }
19
20 System.out.println(s + " is a valid social security number");
21 }
22
23}
24