Question: Write a program that prompts the user to enter a Social Security Number in the format DDD-DD-DDDD, where D is a digit. Your program should

Write a program that prompts the user to enter a Social Security Number in the format DDD-DD-DDDD, where D is a digit. Your program should check whether the input is valid.

//Hint: Use charAt() and isDigit() methods.

Java

Driver main.java

public static void main(String args[]){ ProblemSolution problemSolution = new ProblemSolution(); // Print the result if(problemSolution.isValid()) System.out.print("Valid SSN"); else System.out.print("Invalid SSN"); } }

Problemsolution.java

import java.util.*; import java.lang.*; import java.io.*; class ProblemSolution{ public boolean isValid(){ // Write your code here // Read the SSN Scanner input = new Scanner(System.in);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!