Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Please enter gender, firstName, LastName: Male John Lewis Please enter social security number (DDD-DD-DDDD): 111-2233333 This is not a valid social security number. Please enter social security number (DDD-DD-DDDD): 11-22-3333 This is not a valid social security number. Please enter social security number (DDD-DD-DDDD): 111-22-3333 Thank You John for providing social security number! Your first name is John, your last name is Lewis and your gender is Male
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