-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
60 lines (40 loc) · 1.3 KB
/
Copy pathCustomer.java
File metadata and controls
60 lines (40 loc) · 1.3 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
import java.util.StringTokenizer;
class Customer{
String name,date;
//READ func
void read(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name and date: ");
name = sc.next();
date = sc.next();
}
//display func
void display(){
String delim = "/";//delimiters : breaks the string by the delim
StringTokenizer st = new StringTokenizer(date,delim);
// string tokenizer allows an application to break a string into tokens
System.out.println(name + " ");
while(st.hasMoreElements()){//return true for more tokens
System.out.print(st.nextElement()+" ");//returns next token in the string
}
}
//main
public static void main(String args[]){
int i,n;
System.out.println("Enter number of customers: ");
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
Customer cus[] = new Customer[n];//creates an array of object of that class
for(i=0;i<n;i++){
System.out.println("Enter details for cutomer "+(i+1)+" : ");
cus[i] = new Customer();//allocating for each index
cus[i].read();
}
//display
for(i=0;i<n;i++)
{
cus[i].display();
}
}
}