Escolar Documentos
Profissional Documentos
Cultura Documentos
1 import java.util.*;
2 import java.io.*;
3 class Project
4 {
5 public static void main(String args[])throws IOException
6 {
7 Scanner sc=new Scanner(System.in);
8 System.out.println("1 - Create Data File");
9 System.out.println("2 - Addition of New Records");
10 System.out.println("3 - Report Generation");
11 System.out.println("4 - Deletion of an Account");
12 System.out.println("5 - Modification");
13 System.out.println("6 - Sorting");
14 System.out.println("7 - Exit");
15 int ch=sc.nextInt();
16 switch(ch)
17 {
18 case 1:
19 FileOutputStream foutn=new FileOutputStream("account.dat");
20 DataOutputStream doutn=new DataOutputStream(foutn);
21 doutn.close();
22 foutn.close();
23 break;
24 case 2:
25 FileOutputStream fout=new FileOutputStream("accounttemp.dat")
;
26 DataOutputStream dout=new DataOutputStream(fout);
27 FileInputStream finn=new FileInputStream("account.dat");
28 DataInputStream dinn=new DataInputStream(finn);
29 boolean eoft=false;
30 while(!eoft)
31 {
32 try
33 {
34 long a=dinn.readLong();
35 String n=dinn.readUTF();
36 int am=dinn.readInt();
37 String ad=dinn.readUTF();
38 String adp=dinn.readUTF();
39 dout.writeLong(a);
40 dout.writeUTF(n);
41 dout.writeInt(am);
42 dout.writeUTF(ad);
43 dout.writeUTF(adp);
44 }
45 catch(EOFException n)
46 {
47 eoft=true;
48 }
49 }
50 System.out.println("Enter Account Number");
51 long acc=sc.nextLong();
52 System.out.println("Enter Name");
53 String name=sc.next();
54 System.out.println("Enter Initial Amount To Deposit");
55 int amt=sc.nextInt();
56 System.out.println("Enter Bank Address");
57 String add=sc.next();
58 System.out.println("Enter personal Address");
59 String padd=sc.next();
60 dout.writeLong(acc);
61 dout.writeUTF(name);
62 dout.writeInt(amt);
63 dout.writeUTF(add);
64 dout.writeUTF(padd);
65 dinn.close();
66 finn.close();
67 dout.close();
68 fout.close();
69
98 System.out.println("Name - "+n);
99 System.out.println("Amount Deposited - "+am);
100 System.out.println("Bank Address - "+ad);
101 System.out.println("Personal Address - "+adp)
;
102 }
103
104 }
105 catch(EOFException n )
106 {
107 eof=true;
108 }
109 }
110
111 din.close();
112 fin.close();
113 }
114 else
115 {
116 boolean eof=false;
117 FileInputStream fin=new FileInputStream("account.dat");
118 DataInputStream din=new DataInputStream(fin);
119
120 while(!eof)
121 {
122 try
123 {
124 long a=din.readLong();
125 String n=din.readUTF();
126 int am=din.readInt();
127 String ad=din.readUTF();
128 String adp=din.readUTF();
129 System.out.println("Account Number - "+a);
130 System.out.println("Name - "+n);
131 System.out.println("Amount Deposited - "+am);
132 System.out.println("Bank Address - "+ad);
133 System.out.println("Personal Address - "+adp);
134 }
135 catch(EOFException n)
136 {
137 eof=true;
138 }
139
140 }
141 din.close();
142 fin.close();
143 }
144 break;
145 case 4:
170 }
171 }
172 catch(EOFException n)
173 {
174 eof=true;
175 }
176 }
177 din.close();
178 fin.close();
179 dout1.close();
180 fout1.close();
181 File t1=new File("accounttemp.dat");
182 File t2=new File("account.dat");
183 t2.delete();
184 t1.renameTo(t2);
185 break;
186 case 5:
187 System.out.println("Enter Account Number");
188 long ac2=sc.nextLong();
189 System.out.println("W - Withdrawal");
190 System.out.println("D - Deposit");
191 String ch3=sc.next();
192 FileOutputStream fout2=new FileOutputStream("accounttemp.dat"
);
289 {
290 for(int y=0;y<n2-1;y++)
291 {
292 if(aracc[y]>aracc[y+1])
293 {
294 long ta=aracc[y];
295 aracc[y]=aracc[y+1];
296 aracc[y+1]=ta;
297
337 default:
338 System.out.println("Invalid Input");
339 }
340 }
341 }