Java class called Customer to store their name and date_of_birth. The date_of_birth format should be dd/mm/yyyy. Write methods to read customer data as and display as using StringTokenizer class considering the delimiter character as “/”.

				
					import java.util.Scanner;
import java.util.StringTokenizer;
class customer
{
String name;
String date;
public void read()
{
Scanner input =new Scanner(System.in);
name=input.next();
date=input.next();
}
public void display()
{
System.out.print(name+",");
String delims="/";
StringTokenizer st=new StringTokenizer(date,delims);
while(st.hasMoreElements()){
System.out.print(st.nextElement()+",");
}
System.out.println();
}
public static void main(String[] args)
{
System.out.println("Enter the customer detail");
customer[] cus=new customer[30];
Scanner sc =new Scanner(System.in);

System.out.println("enter the number of customer");
int n=sc.nextInt();
for(int i=0;i
{
cus[i]=new customer();
cus[i].read();
}
for(int i=0;i
cus[i].display();
}
}
				
			
Output:
Enter the customer detail
enter the number of customer
2
Enter the customer name and date
rama
12/2/2018
laxman
11/4/2018

rama,12,2,2018,
laxman,11,4,2018,

Leave a Reply