-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.txt
More file actions
33 lines (33 loc) · 793 Bytes
/
token.txt
File metadata and controls
33 lines (33 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;
import java.util.StringTokenizer;
class Customer{
string name;
string dob;
public void read(){
System.out.println("enter customer name:");
Scanner sc=new Scanner(System.in);
name=sc.next();
System.out.println("enter customer DOB(dd/mm/yyyy:");
dob=sc.next();
String datePattern="\\d{2}/\\d{2}/\\d{4}";
while(!(dob.matches(datePattern))){
System.out.println("please enter the date in dd/mm/yyyy format!");
dob=sc.next();
}
}
public void display(){
StringTokenizer st=new StringTokenizer(dob,"/");
String[]seq=new String[10];
int i;
System.out.println("customer name and DOB is:"+name);
for(i=0;i<3;i++){
System.out.print(","+st.nextToken());
}
System.out.println("\n");
}
public static void main(String[]args){
Customer c1=new Customer();
c1.read();
c1.display();
}
}