project12th .pdf

File information


Original filename: project12th.pdf
Title: Java Printing
Author: Rishu Saxena

This PDF 1.7 document has been generated by / Microsoft: Print To PDF, and has been sent on pdf-archive.com on 08/10/2017 at 13:34, from IP address 47.8.x.x. The current document download page has been viewed 212 times.
File size: 299 KB (8 pages).
Privacy: public file


Download original PDF file


project12th.pdf (PDF, 299 KB)


Share on social networks



Link to this file download page



Document preview


Class Project
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

1/8

import java.util.*;
import java.io.*;
class Project
{
public static void main(String args[])throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.println("1 - Create Data File");
System.out.println("2 - Addition of New Records");
System.out.println("3 - Report Generation");
System.out.println("4 - Deletion of an Account");
System.out.println("5 - Modification");
System.out.println("6 - Sorting");
System.out.println("7 - Exit");
int ch=sc.nextInt();
switch(ch)
{
case 1:
FileOutputStream foutn=new FileOutputStream("account.dat");
DataOutputStream doutn=new DataOutputStream(foutn);
doutn.close();
foutn.close();
break;
case 2:
FileOutputStream fout=new FileOutputStream("accounttemp.dat")
;
DataOutputStream dout=new DataOutputStream(fout);
FileInputStream finn=new FileInputStream("account.dat");
DataInputStream dinn=new DataInputStream(finn);
boolean eoft=false;
while(!eoft)
{
try
{
long a=dinn.readLong();
String n=dinn.readUTF();
int am=dinn.readInt();
String ad=dinn.readUTF();
String adp=dinn.readUTF();
dout.writeLong(a);
dout.writeUTF(n);
dout.writeInt(am);
dout.writeUTF(ad);
dout.writeUTF(adp);
}
catch(EOFException n)
{
eoft=true;
}
30 Jun, 2017 1:41:38 AM

Class Project (continued)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

}
System.out.println("Enter
long acc=sc.nextLong();
System.out.println("Enter
String name=sc.next();
System.out.println("Enter
int amt=sc.nextInt();
System.out.println("Enter
String add=sc.next();
System.out.println("Enter
String padd=sc.next();
dout.writeLong(acc);
dout.writeUTF(name);
dout.writeInt(amt);
dout.writeUTF(add);
dout.writeUTF(padd);
dinn.close();
finn.close();
dout.close();
fout.close();

2/8
Account Number");
Name");
Initial Amount To Deposit");
Bank Address");
personal Address");

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

File tn1=new File("accounttemp.dat");
File tn2=new File("account.dat");
tn2.delete();
tn1.renameTo(tn2);
break;
case 3:
System.out.println("1 - Specific Account");
System.out.println("2 - For All Accounts");
int ch2=sc.nextInt();
if(ch2==1)
{
System.out.println("Enter Account Number");
long ac=sc.nextLong();
FileInputStream fin=new FileInputStream("account.dat");
DataInputStream din=new DataInputStream(fin);
boolean eof=false;
while(!eof)
{
try
{
long a=din.readLong();
String n=din.readUTF();
int am=din.readInt();
String ad=din.readUTF();
String adp=din.readUTF();
if(a==ac)
{
System.out.println("Account Number - "+a);
30 Jun, 2017 1:41:38 AM

Class Project (continued)

3/8
System.out.println("Name - "+n);
System.out.println("Amount Deposited - "+am);
System.out.println("Bank Address - "+ad);
System.out.println("Personal Address - "+adp)

98
99
100
101

;
}

102
103

}
catch(EOFException n )
{
eof=true;
}

104
105
106
107
108
109

}

110
111
112
113
114
115
116
117
118

din.close();
fin.close();
}
else
{
boolean eof=false;
FileInputStream fin=new FileInputStream("account.dat");
DataInputStream din=new DataInputStream(fin);

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

while(!eof)
{
try
{
long a=din.readLong();
String n=din.readUTF();
int am=din.readInt();
String ad=din.readUTF();
String adp=din.readUTF();
System.out.println("Account Number - "+a);
System.out.println("Name - "+n);
System.out.println("Amount Deposited - "+am);
System.out.println("Bank Address - "+ad);
System.out.println("Personal Address - "+adp);
}
catch(EOFException n)
{
eof=true;
}

139
140
141
142
143
144
145

}
din.close();
fin.close();
}
break;
case 4:
30 Jun, 2017 1:41:38 AM

Class Project (continued)

4/8

System.out.println("Enter Account Number");
long ac1=sc.nextLong();
FileOutputStream fout1=new FileOutputStream("accounttemp.dat"

146
147
148

);
DataOutputStream dout1=new DataOutputStream(fout1);
FileInputStream fin=new FileInputStream("account.dat");
DataInputStream din=new DataInputStream(fin);
boolean eof=false;
while(!eof)
{
try
{
long a1=din.readLong();
String n1=din.readUTF();
int am1=din.readInt();
String ad1=din.readUTF();
String adp1=din.readUTF();
if(ac1!=a1)
{
dout1.writeLong(a1);
dout1.writeUTF(n1);
dout1.writeInt(am1);
dout1.writeUTF(ad1);
dout1.writeUTF(adp1);

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

}
}
catch(EOFException n)
{
eof=true;
}

170
171
172
173
174
175

}
din.close();
fin.close();
dout1.close();
fout1.close();
File t1=new File("accounttemp.dat");
File t2=new File("account.dat");
t2.delete();
t1.renameTo(t2);
break;
case 5:
System.out.println("Enter Account Number");
long ac2=sc.nextLong();
System.out.println("W - Withdrawal");
System.out.println("D - Deposit");
String ch3=sc.next();
FileOutputStream fout2=new FileOutputStream("accounttemp.dat"

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

);
30 Jun, 2017 1:41:38 AM

Class Project (continued)

5/8

DataOutputStream dout2=new DataOutputStream(fout2);
FileInputStream fin1=new FileInputStream("account.dat");
DataInputStream din1=new DataInputStream(fin1);
boolean eof1=false;
while(!eof1)
{
try
{
long a1=din1.readLong();
String n1=din1.readUTF();
int am1=din1.readInt();
String ad1=din1.readUTF();
String adp1=din1.readUTF();
if(ac2==a1)
{
if(ch3.equalsIgnoreCase("W"))
{
int wa=0;
do
{
System.out.println("Enter amount to withd

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

raw");
wa=sc.nextInt();
}while(wa<1000);
am1-=wa;

214
215
216

}
else if(ch3.equalsIgnoreCase("D"))
{
System.out.println("Enter amount to deposit")

217
218
219
220

;
int da=sc.nextInt();
am1+=da;

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

}
}
dout2.writeLong(a1);
dout2.writeUTF(n1);
dout2.writeInt(am1);
dout2.writeUTF(ad1);
dout2.writeUTF(adp1);
}
catch(EOFException n)
{
eof1=true;
}
}
din1.close();
fin1.close();
dout2.close();
fout2.close();
30 Jun, 2017 1:41:39 AM

Class Project (continued)
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

6/8

File t11=new File("accounttemp.dat");
File t21=new File("account.dat");
t21.delete();
t11.renameTo(t21);
break;
case 6:
FileInputStream fin2=new FileInputStream("account.dat");
DataInputStream din2=new DataInputStream(fin2);
boolean eof2=false;
int n2=0;
while(!eof2)
{
try
{
long a1=din2.readLong();
String n1=din2.readUTF();
int am1=din2.readInt();
String ad1=din2.readUTF();
String adp1=din2.readUTF();
n2++;
}
catch(EOFException n)
{
eof2=true;
}
}
din2.close();
fin2.close();
long aracc[]=new long[n2];
String arna[]=new String[n2];
int aram[]=new int[n2];
String aradd[]=new String[n2];
String aradp[]=new String[n2];
FileInputStream fin3=new FileInputStream("account.dat");
DataInputStream din3=new DataInputStream(fin3);
for(int x=0;x<n2;x++)
{
long a1=din3.readLong();
aracc[x]=a1;
String n1=din3.readUTF();
arna[x]=n1;
int am1=din3.readInt();
aram[x]=am1;
String ad1=din3.readUTF();
aradd[x]=ad1;
String adp1=din3.readUTF();
aradp[x]=adp1;
}
for(int x=0;x<n2;x++)
30 Jun, 2017 1:41:39 AM

Class Project (continued)

7/8

{

289

for(int y=0;y<n2-1;y++)
{
if(aracc[y]>aracc[y+1])
{
long ta=aracc[y];
aracc[y]=aracc[y+1];
aracc[y+1]=ta;

290
291
292
293
294
295
296
297

String tn=arna[y];
arna[y]=arna[y+1];
arna[y+1]=tn;

298
299
300
301

int tam=aram[y];
aram[y]=aram[y+1];
aram[y+1]=tam;

302
303
304
305

String tad=aradd[y];
aradd[y]=aradd[y+1];
aradd[y+1]=tad;

306
307
308
309

String tap=aradp[y];
aradp[y]=aradp[y+1];
aradp[y+1]=tap;

310
311
312

}

313

}

314

}
din3.close();
fin3.close();
FileOutputStream fout3=new FileOutputStream("accounttemp.dat"

315
316
317
318

);
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336

DataOutputStream dout3=new DataOutputStream(fout3);
for(int x=0;x<n2;x++)
{
dout3.writeLong(aracc[x]);
dout3.writeUTF(arna[x]);
dout3.writeInt(aram[x]);
dout3.writeUTF(aradd[x]);
dout3.writeUTF(aradp[x]);
}
dout3.close();
fout3.close();
File ts1=new File("accounttemp.dat");
File ts2=new File("account.dat");
ts2.delete();
ts1.renameTo(ts2);
break;
case 7:
break;
30 Jun, 2017 1:41:39 AM

Class Project (continued)
default:
System.out.println("Invalid Input");

337
338

}

339

}

340
341

8/8

}

30 Jun, 2017 1:41:39 AM


Related documents


project12th
2012 f hw1 1
sheet 2 2015
lista6
pract
how to create pdf using java with formatting text

Link to this page


Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..

Short link

Use the short link to share your document on Twitter or by text message (SMS)

HTML Code

Copy the following HTML code to share your document on a Website or Blog

QR Code

QR Code link to PDF file project12th.pdf