Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

simulate a program in JAVA that asks the user for all of their contact informati

ID: 3534793 • Letter: S

Question

simulate a program in JAVA that asks the user for all of their contact information (Name, phone number, address, zip code, city, state and birthday)

With each of these fields we should be able to enter very specific data; if we do not enter data that fits our criteria then we should warn the user and let them retry entering the data.

Name – First and Last (allow numbers, letters and special characters)

Address - allow numbers, letters and special characters

Zip code – allow only 5 numbers – no special characters

City – allow numbers, letters and special characters

State – Allow only 2 letters (extra credit if you only allow current state abbreviations)

Birthday – use a mm-DD-YYYY format and only accept valid dates

Explanation / Answer

Here is Your Progarme All working..

Hope You like..:)

import java.text.DateFormat;

import java.util.Date;

import java.util.Scanner;


public class firstproject {

public static void main(String[] args) {

Scanner stdin = new Scanner(System.in);

String FirstName;

String LastName;

String Address;

int zip = 0;

System.out.print("Enter Your First Name : ");

FirstName = stdin.next();

System.out.print("Enter Your Last Name : ");

LastName = stdin.next();

stdin.next();

System.out.print("Enter Your Address Name : ");

Address = stdin.nextLine();

int flag = 0;

while ( flag == 0){

System.out.print("Enter Your Zip Code( must be 5 digit ) : ");

zip = stdin.nextInt();

if ( ((zip) > 9999) Â && ((zip) < 100000) ) Â flag = 1;

if( flag == 0) System.out.println("****You have entered wrong zip code please try again... ");

}

String city;

System.out.print("Enter Your City Name : ");

city = stdin.next();

String Statecode = "UP";

flag = 0;

while ( flag == 0){

System.out.print("Enter Your State Code( must be 2 character ) : ");

Statecode = stdin.next();

if ( Statecode.length() == 2 ) flag = 1;

if( flag == 0) System.out.println("****You have entered wrong State code please try again... ");

}

String dob = "17-09-1992";

flag = 0;

while ( flag == 0){

System.out.print("Enter Your DateofBirth ( format : dd-mm-yyyy ) : ");

dob = stdin.next();

if ( ( dob.charAt(2) == '-') && ( dob.charAt(5) == '-') Â ) Â flag = 1;

if( flag == 0) System.out.println("****You have entered wrong Date please try again... ");

}


System.out.println("All input are taken..");

System.out.println("- - - - - - - - - - - - - - - - - - - - ");

System.out.println("First Name : " + FirstName);

System.out.println("Last Name : " + LastName);

System.out.println("Address : " + Address);

System.out.println("zip : " + zip);

System.out.println("City : " + city);

System.out.println("State Code : " + Statecode );

System.out.println("Date of Birth : " + dob);

}

}