Question
Write a Java program that asks user to enter gender, first name and last name in one string. The program should extract the gender, first
Write a Java program that asks user to enter gender, first name and last name in one string. The program should extract the gender, first and last name from the string and should print this information as per output shown below (Assume the user has only first and last name). Then program should prompt 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. Take this number from user in the form of string. The program should keep on asking the user about the social security number until user enters a valid social security number.
Hint: Use length() function to check total length of social security number. Also check that you must have a - at index 3 and index 6 of string and digits at remaining indexes.
Output
Specifications
-
The program should ask person for gender, first and last name, extract information and print it.
(Marks 3)
-
The program should ask person for social security number and check if it is valid. (Marks 4)
-
The program should keep on running using while loop until user enters a valid social security number. (Marks 3)
In your code at the top you should have, This project is submitted by ______ (where ____ should be filled by student name and id.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started