-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path28.1 Bank AC Opeer.java
111 lines (92 loc) · 2.27 KB
/
28.1 Bank AC Opeer.java
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
Jalandhar Public Bank has recently launched the Provident Fund Scheme and the CEO of the bank is looking for a java program to create a Provident Fund object such that customer should be allowed to open the account by providing any one of the id proofs Aadhar (long) or PAN (String) along with Full Name. It is also expected that the unique account number is assigned to the Customer in a serial order starting from A101 for Aadhar Card holders and P101 for PAN holders.
Input Format
First line reads the number of accounts to be opened N
N times,
Read the Name of the Customer
read the character (A/ P)
read the Aadhar Number of PAN accordingly
Constraints
N>0
Output Format
Prints the Account Numbers in separate lines
Sample Input 0
2
Amit Dutta
P
DUAPS7896P
Sanjeev
A
512233213490
Sample Output 0
P101
A101
Sample Input 1
2
Md. Azharuddin
A
GHBRQ2718A
Surinder Singh
A
MPUPS3878D
Sample Output 1
A101
A102
*/
import java.io.*;
import java.util.*;
class JPB
{
String name;
String PAN;
String Aadhar;
String CN;
static int ACN = 101;
static int PCN = 101;
JPB(String name)
{
this.name = name;
}
void getOpenA(String A)
{
Aadhar = A;
CN = "A"+Integer.toString(ACN++);
}
void getOpenP(String P)
{
PAN = P;
CN = "P"+Integer.toString(PCN++);
}
}
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String name;
char c;
JPB [] j = new JPB[n];
for(int i=0;i<n;i++)
{
if(i!=0)
sc.nextLine();
name = sc.nextLine();
c = sc.next().charAt(0);
if(c=='A')
{
String adh = sc.next();
j[i] = new JPB(name);
j[i].getOpenA(adh);
System.out.println(j[i].CN);
}
else if(c=='P')
{
String pan = sc.next();
j[i] = new JPB(name);
j[i].getOpenP(pan);
System.out.println(j[i].CN);
}
}
}
}