-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathManage2.java
More file actions
1393 lines (1109 loc) · 56.8 KB
/
Manage2.java
File metadata and controls
1393 lines (1109 loc) · 56.8 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import java.util.Scanner;
import java.util.Random;
import java.util.Calendar;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Account // 계좌클래스
{
// private → accountNumber, name, password,
private String accountNumber; //계좌
private String name; //사용자 이름
private String password; //계좌 비밀번호
private int accountBalance; //계좌잔액
private String jumin; //주민등록번호
String savingName; //적금이름
private String savingNum; //적금 계좌
private double savingBalance; //적금 잔액
double savingLastBalance; //적금 만기잔액
private int point; //제휴포인트
int deposit; //입금
int withdraw; //출금
//setter()
public void setaccountNumber(String accountNumber) {this.accountNumber = accountNumber;}
public void setname(String name) {this.name = name;}
public void setpassword(String password) {this.password = password;}
public void setaccountBalance(int accountBalance) {this.accountBalance = accountBalance;}
public void setjumin(String jumin) {this.jumin = jumin;}
public void setsavingNum(String savingNum) {this.savingNum = savingNum;}
public void setsavingBalance(double savingBalance) {this.savingBalance = savingBalance;}
//getter()
public String getaccountNumber() { return accountNumber;}
public String getname() { return name;}
public String getpassword() {return password;}
public int getaccountBalance() {return accountBalance;}
public String getjumin() {return jumin;}
public String getsavingNum() {return savingNum;}
public double getsavingBalance() {return savingBalance;}
}
public class Manage2
{
Scanner sc= new Scanner(System.in);
Calendar ca = Calendar.getInstance();
double RateEnhwa = 1120.0;
double Ratedollar = 1200.0;
double RateWean = 1000.0;
double RateEuro = 2200.0;
Account[] acArray=new Account[100];
String pname; // 사용자가 입력한 이름이 저장될 변수
String pAccountNum; // 사용자가 입력한 계좌번호가 저장될 변수
String ppw; // 사용자가 입력한 비밀번호가 저장될 변수
int inM, outM;
int a;
int inwon;
// 도움말 메소드
public void help()
{
System.out.println();
System.out.println(" ■ 서비스 이용시간 ■");
System.out.println("=========================================");
System.out.println(" 24시간 365일");
System.out.println("( 00:00 ~ 00:30 사이에는 시스템 점검으로");
System.out.println(" 서비스 이용 불가합니다.");
System.out.println();
System.out.println(" ■ 이용안내 ■");
System.out.println("=========================================");
System.out.println(" 1. 첫 화면에서 원하시는 버튼을 선택");
System.out.println(" 2. [ 계좌 (개설, 조회, 해지) 선택 ]");
System.out.println(" 3. [ 항목에 따라 고객 정보 입력 ]");
System.out.println();
System.out.println(" ■ 출금 수수료 ■");
System.out.println("=========================================");
System.out.println(" 동일 은행 이체시 : 수수료 없음.");
System.out.println(" 타행 은행 이체시 : 수수료 500원.");
System.out.println();
System.out.println(" ■ 유의사항 ■");
System.out.println("=========================================");
System.out.println(" ① 계좌 조회 & 입출금 & 계좌 이체 시,");
System.out.println(" 성함, 계좌번호, 비밀번호가 필요합니다.");
System.out.println(" ② 인증되지 않은 센터에서 비밀번호 요구시");
System.out.println(" 고객센터로 반드시 문의 바랍니다.");
System.out.println(" ③ 계좌번호, 비밀번호 분실 시");
System.out.println(" 고객센터로 문의 바랍니다.");
System.out.println();
System.out.println(" ■ 제휴서비스 ■");
System.out.println("=========================================");
System.out.println(" 일반고객 : 보유 잔액 ~ 500만원");
System.out.println(" vip 고객 : 보유 잔액 500만원 ~ 5000만원");
System.out.println(" vvip 고객 : 보유 잔액 5000만원~5억");
System.out.println();
System.out.println(" ☏☎ 고객센터 : 02) 336 - 8546 ");
System.out.println();
}
// 계좌 개설 메소드
public void openAccount()
{
// 주민등록번호 유효성 검사에 필요한 변수들
int sum=0;
int[] num = {2,3,4,5,6,7,0,8,9,2,3,4,5};
int namuji;
int n,a;
Scanner sc= new Scanner(System.in);
// Account클래스 기반 인스턴스를 inwon크기 만큼 생성
acArray[inwon] = new Account();
try
{
// 이름 입력받기
System.out.print("▶ 이름을 입력하세요: ");
acArray[inwon].setname(sc.next());
// 주민등록번호 입력받기
System.out.print("▶ 주민등록번호를 입력하세요: ");
acArray[inwon].setjumin(sc.next());
// 주민등록번호 유효성 검사
if(acArray[inwon].getjumin().length() != 14)
System.out.println(">>입력 오류~!!!");
for(int i=0; i<num.length;i++)
{
if(i==6)
continue;
sum += num[i] * Integer.parseInt(acArray[inwon].getjumin().substring(i,i+1));
}
namuji = (11-sum%11)%10;
// 주민등록번호가 유효한 경우
if(namuji==Integer.parseInt(acArray[inwon].getjumin().substring(13)))
{
// 계좌 개설
// 적금 계좌 생성 여부 확인
System.out.print("▶ 적금 계좌를 생성하시겠습니까 (YES : 1) OR (No : 2) ");
n=sc.nextInt();
System.out.print("▶ 일반 계좌를 생성하시겠습니가 (YES : 1) OR (No : 2) ");
a = sc.nextInt();
// 계좌 생성 메소드 호출
createAccount(n,a);
// 적금계좌와 일반계좌 둘다 안만든다면 종료
if(n==2 && a==2)
return;
// 잔액 출력
System.out.println("【일반 계좌잔액】:"+acArray[inwon].getaccountBalance()+"원");
System.out.println();
}
// 주민번호가 유효하지 않은 경우
else
{
System.out.println("※※※ 유효하지 않은 주민번호~!!! ※※※");
return;
}
}
catch (NullPointerException e)
{
System.out.println("올바른 문자를 입력해주세요 ! " );
}
} // end openAccount
// 계좌 생성 메소드
public void createAccount(int j,int k)
{
int c;
// 적금계좌 앞자리 은행 고유번호 1111로 초기화
String a="1111";
// 일반계좌 앞자리 은행 고유번호 2222로 초기화
String b="2222";
Random rd = new Random();
acArray[inwon].setaccountBalance(0); // 계좌 생성 시 잔액 초기화
if( j==1 && k==1) // 적금 O 일반 계좌 O
{
// 적금계좌와 일반계좌를 랜덤함수를 사용하여 계좌번호 생성
// 고유번호 앞자리 4자리를 제외한 10자리 생성하므로 10번 반복하여 생성
for(int i=0; i<10; i++)
{
a+=Integer.toString(rd.nextInt(9));
acArray[inwon].setsavingNum(a);
b+=Integer.toString(rd.nextInt(9));
acArray[inwon].setaccountNumber(b);
}
// 목록 메소드 호출
moklok();
// 비밀번호 설정 메소드 호출
createpassword();
// 결과 출력
System.out.println();
System.out.println(acArray[inwon].getname()+"님의 【적금 계좌번호】 : "+acArray[inwon].getsavingNum());
System.out.printf("%s님의 【일반 계좌번호】 : %s \n",acArray[inwon].getname(),acArray[inwon].getaccountNumber());
}
else if(j==1 && k==2) //적금 O 일반 계좌 X
{
// 적금계좌만 랜덤함수 사용하여 계좌번호 생성
for(int i=0; i<10; i++)
{
a+=Integer.toString(rd.nextInt(9));
acArray[inwon].setsavingNum(a);
}
moklok();
createpassword();
System.out.println();
System.out.println(acArray[inwon].getname()+"님의 【적금 계좌번호】:"+acArray[inwon].getsavingNum());
}
else if(j==2 && k==1) // 적금 X 일반 계좌 O
{
// 일반계좌만 랜덤함수 사용하여 계좌번호 생성
for(int i=0; i<10; i++)
{
b+=Integer.toString(rd.nextInt(9));
acArray[inwon].setaccountNumber(b);
}
createpassword();
System.out.printf("%s님의 【일반 계좌번호】 :%s\n",acArray[inwon].getname(),acArray[inwon].getaccountNumber());
}
else if(j==2 && k==2) // 적금 X 일반 계좌 X
System.out.println("다시 이용해주세요 ! ");
} // end creatAccount
// 목록 메소드
public void moklok() // j==1 일때 호출. ( 적금 목록과 적금 이율 계산 메소드 )
{
int c; // 사용자에게 입력받을 번호를 저장할 변수
double interest=1; // 이자를 1로 초기화
int y=1; // 이자 계산 시 필요한 변수를 1로 초기화
System.out.println();
System.out.println("적금 상품 목록을 선택하세요 ");
// 적금상품 선택
System.out.print("【1.자유적금(이자율:0.1%)-계약 기간 1년】 \n【2.쌍용적금(이자율:0.2%)-계약 기간 2년】 \n【3.청춘적금(이자율:0.3%)-계약 기간 3년】\n");
System.out.print("▶ 원하시는 상품을 번호로 선택해주세요. (1, 2, 3) : ");
c=sc.nextInt();
System.out.println();
// 사용자가 선택한 적금상품을 사용자 정보의 적금상품이름에 저장
switch (c)
{
case 1:
acArray[inwon].savingName="1.자유적금(이자율:0.1%)계약 기간 1년";
break;
case 2:
acArray[inwon].savingName="2.쌍용적금(이자율:0.2%)계약 기간 2년";
break;
case 3:
acArray[inwon].savingName="3.청춘적금(이자율:0.3%)계약 기간 3년";
break;
}
// 월마다 입금할 금액 입력받기
// 만원 미만 입력하면 계속 반복
do
{
System.out.print("월마다 넣을 금액 입력 (10000원이상): ");
acArray[inwon].setsavingBalance(sc.nextDouble());
if(acArray[inwon].getsavingBalance()>=10000)
continue;
System.out.println("만원 이상 넣어주세요 !!");
}while (acArray[inwon].getsavingBalance()<10000);
// 사용자가 선택한 상품별로 이자 계산 수식
switch(c) // 단리 (이자에 이자가 없음)
{
//
case 1:
{
acArray[inwon].savingLastBalance=(acArray[inwon].getsavingBalance()*12)+(acArray[inwon].getsavingBalance()*(interest*0.1));
break;
}
case 2:
{
y=2;
acArray[inwon].savingLastBalance=(acArray[inwon].getsavingBalance()*24)+(acArray[inwon].getsavingBalance()*(interest*0.2));
break;
}
case 3:
{
y=3;
acArray[inwon].savingLastBalance=(acArray[inwon].getsavingBalance()*36)+(acArray[inwon].getsavingBalance()*(interest*0.3));
break;
}
} //end switch
//적금가입날짜 - 현재날짜 출력\
System.out.println();
System.out.println("적금가입날짜: " + ca.get(Calendar.YEAR) + "-" +(ca.get(Calendar.MONTH)+1)+ "-" + ca.get(Calendar.DATE));
//사용자가 선택한 상품에 따른 결과 출력
//1번 상품
if(y==1)
{
//만기년도를 출력하기 위해 add메소드 사용
ca.add(Calendar.YEAR,y);
System.out.println("=============================================================================");
//이자율 출력
System.out.println(acArray[inwon].getname()+"의 적금 이자율 : " + interest*0.1 +"%");
//적금만기금액 출력
System.out.println("자유적금 1년뒤 적금 만기 금액 :"+(int)acArray[inwon].savingLastBalance+"원");
//만기일 출력
System.out.println("자유적금 만기일 : "+ ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH)+1) + "-" + ca.get(Calendar.DATE));
System.out.println("=============================================================================");
}
//2번 상품
else if(y==2)
{
//만기년도를 출력하기 위해 add메소드 사용
ca.add(Calendar.YEAR,y);
System.out.println("=============================================================================");
System.out.println(acArray[inwon].getname()+"의 적금 이자율 :"+ interest*0.2+"%");
System.out.println("쌍용적금 2년뒤 적금 만기 금액 :"+(int)acArray[inwon].savingLastBalance+"원");
System.out.println("쌍용적금 만기일 : "+ ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH)+1) + "-" + ca.get(Calendar.DATE));
System.out.println("=============================================================================");
}
//3번 상품
else if(y==3)
{
//만기년도를 출력하기 위해 add메소드 사용
ca.add(Calendar.YEAR,y);
System.out.println("=============================================================================");
System.out.println(acArray[inwon].getname()+"의 적금 이자율 : " + + interest*0.3+"%");
System.out.println("청춘적금 3년뒤 적금 만기 금액 :"+(int)acArray[inwon].savingLastBalance+"원");
System.out.println("청춘적금 만기일 : "+ ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH)+1) + "-" + ca.get(Calendar.DATE));
System.out.println("=============================================================================");
}
} //end moklok
//비밀번호 설정 메소드
public void createpassword()
{
//비밀번호 설정
do
{
System.out.println();
System.out.println("■■■ 비밀번호 설정 ■■■");
System.out.print("▶ (4자리)비밀번호를 입력하세요 : ");
acArray[inwon].setpassword(sc.next());
}
while (acArray[inwon].getpassword().length() != 4); //비밀번호가 4자리가 아니면 다시 입력 요청
} // end createpasword
public void deleteAccount()
{
//Account ac = new Account();
int i,j; //반복문을 위한 변수
String account; //사용자에게 입력받을 해지할 계좌 저장
Scanner sc = new Scanner(System.in);
//해지할 계좌번호 사용자에게 입력받기
System.out.print("해지할 계좌번호를 입력해주세요 : ");
account = sc.next();
try
{
//배열에서 해당 계좌번호 검색
for (i=0; i < inwon+1; i++)
{
//저장된 계좌번호와 사용자가 입력한 계좌번호가 같다면 해지
if (acArray[i].getaccountNumber().equals(account))
{
//만약 해지할 계좌번호가 배열의 마지막 방일 경우
if(i==inwon)
inwon--; //배열의 수를 감소시켜서 제거
//해지할 계좌번호가 마지막 방이 아닐 경우
else
{
//해당계좌가 들어있는 배열방을 기준으로 뒤의 배열들을 앞으로 모두 이동시킨다.
for (j=i; j<inwon+1;j++ )
{
acArray[j]=acArray[j+1];
/*
acArray[j].setaccountNumber(acArray[j+1].getaccountNumber());
acArray[j].setname(acArray[j+1].getname());
acArray[j].setpassword(acArray[j+1].getpassword());
acArray[j].setaccountBalance(acArray[j+1].getaccountBalance());
acArray[j].setaccountNumber(acArray[j+1].getaccountNumber());
acArray[j].setjumin(acArray[j+1].getjumin());
acArray[j].setsavingNum(acArray[j+1].getsavingNum());
acArray[j].setsavingBalance(acArray[j+1].getsavingBalance());
*/
}
//모두 앞으로 이동시킨 후, 하나가 제거되었으므로 배열의 크기를 1 줄여준다.
inwon--;
}
System.out.println(inwon);
System.out.println("해지되었습니다.");
System.out.println();
}
//만약 저장된 계좌번호가 사용자가 입력한 계좌번호와 같지 않다면
else
{
//배열의 끝까지 탐색이 완료되었다면
if(i==inwon)
{
//메시지 출력
System.out.println("계좌번호가 일치하지 않습니다");
return;
}
}
} //end for
} //end try
//NullPointerException 발생하면 catch
catch (NullPointerException e)
{
}
} // end deleteCount
// 입/출금 선택 & 계좌번호(이름) 조회 메소드 정의
public void input()
{
Scanner sc = new Scanner(System.in);
// 주요 변수 선언
int select; // 입출금 선택 변수
//입금, 출금 선택
do
{
System.out.print(" 입금---(1) / 출금---(2) : ");
select = sc.nextInt();
}
while (select<1 || select>2);
System.out.print(" 고객님의 【성함】을 입력해주세요. : ");
pname = sc.next();
System.out.print(" 고객님의 【계좌 번호】를 입력해주세요(숫자만 입력). : ");
pAccountNum = sc.next();
System.out.print(" 고객님의 【비밀번호】를 입력해주세요. : ");
ppw = sc.next();
if (select==1) // 입금을 선택했으면
inMoney(); // 입금 메소드 호출
if (select==2) // 출금을 선택했으면
outMoney(); // 출금 메소드 호출
} //end input()
// 입금 메소드 정의
public void inMoney()
{
Scanner sc = new Scanner(System.in);
System.out.println("【입금 메소드 처리시작】");
//배열탐색
for (int i=0; i<inwon+1; i++)
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw))) // 계좌번호 일치 『or』 비밀번호 일치
{
if(acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 O
{
System.out.println("계좌번호, 비밀번호가 일치합니다.");
//결과 출력
System.out.println();
System.out.println("==============================================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
System.out.println(" 현재 잔액 조회 : " + acArray[i].getaccountBalance());
System.out.println("==============================================================");
System.out.println();
//입금금액 입력받기
System.out.print(" 얼마를 입금 하시겠습니까? : ");
inM = sc.nextInt();
System.out.println(" 입금 금액 : " + inM);
//잔액에 입금금액을 누적시킨다
a = acArray[i].getaccountBalance();
a += inM;
acArray[i].setaccountBalance(a);
System.out.println("=================================================");
System.out.println(" 입금 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
if(!acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw))// 계좌번호 일치 X 『and』 비밀번호 일치 O
{
//메시지 출력
System.out.println("비밀번호는 일치하지만, 계좌번호가 틀렸습니다.");
break;
}
if(acArray[i].getaccountNumber().equals(pAccountNum) && !acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 X
{
//메시지 출력
System.out.println("계좌번호는 일치하지만, 비밀번호가 틀렸습니다.");
break;
}
} //end if
else // 계좌번호 일치 X 『and』 비밀번호 일치 X
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw)) && i==(acArray.length)) // 반복문이 마지막 배열까지 돌았을 경우
{
System.out.println("일치하는 정보가 없습니다."); // 일치하는 정보가 없다고 출력한 후 종료.
break;
}
} //end else
} // end for
} //end inMoney()
// 출금 메소드 정의
public void outMoney()
{
Scanner sc = new Scanner(System.in);
System.out.println("출금 메소드 처리시작");
for (int i=0; i<acArray.length; i++)
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw))) // 계좌번호 일치 『or』 비밀번호 일치
{
if(acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 O
{
System.out.println("계좌번호, 비밀번호가 일치합니다.");
//결과 출력
System.out.println();
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
System.out.println(" 현재 잔액 조회 : " + acArray[i].getaccountBalance());
System.out.println();
//출금금액 입력받기
System.out.print(" 얼마를 출금 하시겠습니까? : ");
outM = sc.nextInt();
//만약 잔액이 출금금액보다 적다면
if (acArray[i].getaccountBalance()<outM)
{
System.out.println("출금가능금액이 한도초과 되었습니다. 감사합니다.");
System.out.println();
break;
}
System.out.println(" 출금 금액 : " + outM);
//출금 금액 누적감소
a-=outM;
acArray[i].setaccountBalance(a);
System.out.println("=================================================");
System.out.println(" 출금 후 금액 : " + acArray[i].getaccountBalance());
break;
}
if(!acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 X 『and』 비밀번호 일치 O
{
System.out.println("비밀번호는 일치하지만, 계좌번호가 틀렸습니다.");
break;
}
if(acArray[i].getaccountNumber().equals(pAccountNum) && !acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 X
{
System.out.println("계좌번호는 일치하지만, 비밀번호가 틀렸습니다.");
break;
}
}
else // 계좌번호 일치 X 『and』 비밀번호 일치 X
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw)) && i==(acArray.length)) // 반복문이 마지막 배열까지 돌았을 경우
{
System.out.println("일치하는 정보가 없습니다."); // 일치하는 정보가 없다고 출력한 후 종료.
break;
}
} //end else
}// end for
}//end outMoney()
// 계좌 이체 메소드 정의 (타행이체, 당행이체)
public void sendmoney()
{
int i=0,j=0; // 반복문 수행을 위한 변수 선언 및 초기화
int sendm=0; // 입력되는 이체금액을 담아둘 변수 선언 및 초기화
Scanner sc = new Scanner(System.in);
System.out.print("고객님의 성함을 입력하세요 : ");
String customer_name = sc.next();
System.out.print("고객님의 계좌를 입력하세요 : ");
String customer = sc.next();
System.out.print("고객님 계좌의 비밀번호를 입력하세요 : ");
String customer_password = sc.next();
for (i=0; i<acArray.length; i++) // 배열의 길이만큼(고객 수 만큼) 반복문 수행
{
if (acArray[i].getaccountNumber().equals(customer) || (acArray[i].getpassword().equals(customer_password))) // 계좌번호 일치 『or』 비밀번호 일치
{
if(acArray[i].getaccountNumber().equals(customer) && acArray[i].getpassword().equals(customer_password)) // 계좌번호 일치 O 『and』 비밀번호 일치 O
{
System.out.print("이체하실 계좌번호를 입력해주세요 : ");
String guest = sc.next();
System.out.print("얼마를 이체 하시겠습니까? : ");
sendm = sc.nextInt();
if (acArray[i].getaccountBalance()<sendm+500) // 보유 잔액이 이체 금액보다 적은 경우
{
System.out.println("※※※※※ 출금가능금액이 한도초과 되었습니다. ※※※※※"); // 한도 초과 출력문 표시
break;
}
try
{
if (guest.length()!=14) // 타행이체
{
acArray[i].setaccountBalance(acArray[i].getaccountBalance()-sendm-500); // 현재 보유 잔액에서 - 이체 금액 - 수수료(500원)
System.out.println("=============================================================================================================");
System.out.printf("%s에 %d원 이체했습니다. \n타행이체 수수료는 500원 입니다. \n남은 잔액은 %d원 입니다.\n",guest,sendm,acArray[i].getaccountBalance());
}
else // 당행 이체
{
acArray[i].setaccountBalance(acArray[i].getaccountBalance()-sendm);
System.out.println("=============================================================================================================");
System.out.printf("%s에 %d원 이체했습니다. \n남은 잔액은 %d원 입니다.\n",guest,sendm,acArray[i].getaccountBalance());
for (j=0; j<acArray.length+1; j++)
{
if (acArray[j].getaccountNumber().equals(guest)) // 반복문 돌리면서 이체되는 계좌번호와, 고객 정보가 일치하게 되면
acArray[j].setaccountBalance((acArray[j].getaccountBalance())+sendm); // 현재 보유 잔액에서 이체 금액을 추가한 금액으로 저장.
}
System.out.printf("%s에 %d원 이체했습니다. 남은 잔액은 %d원 입니다.",guest,sendm,acArray[i].getaccountBalance());
}
}
catch (NullPointerException e)
{
}
System.out.println("계좌번호, 비밀번호 일치O");
break;
}
if(!acArray[i].getaccountNumber().equals(customer) && acArray[i].getpassword().equals(customer_password)) // 계좌번호 일치 X 『and』 비밀번호 일치 O
{
System.out.println("비밀번호는 일치하지만, 계좌번호가 틀렸습니다.");
break;
}
if(acArray[i].getaccountNumber().equals(customer) && !acArray[i].getpassword().equals(customer_password)) // 계좌번호 일치 O 『and』 비밀번호 일치 X
{
System.out.println("계좌번호는 일치하지만, 비밀번호가 틀렸습니다.");
break;
}
}
else
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw)) && i==(acArray.length)) // 반복문이 마지막 배열까지 돌았을 경우
{
System.out.println("일치하는 정보가 없습니다."); // 일치하는 정보가 없다고 출력한 후 종료.
break;
}
}
}
}
// 지정된 환율에 따른 환전 메소드 정의
public void exchange()
{
int i;
Scanner sc = new Scanner(System.in); // Scanner 클래스 인스턴스 생성
System.out.print(" 고객님의 【성함】을 입력해주세요. : ");
pname = sc.next();
System.out.print(" 고객님의 【계좌 번호】를 입력해주세요(숫자만 입력). : ");
pAccountNum = sc.next();
System.out.print(" 고객님의 【비밀번호】를 입력해주세요. : ");
ppw = sc.next();
try
{
for (i=0; i<acArray.length; i++)
{
if (acArray[i].getaccountNumber().equals(pAccountNum) || (acArray[i].getpassword().equals(ppw))) // 계좌번호 일치 『or』 비밀번호 일치
{
if(acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 O
{
System.out.println("계좌번호, 비밀번호 일치O");
System.out.println();
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
System.out.println(" 현재 잔액 조회 : " + acArray[i].getaccountBalance());
System.out.println();
System.out.print("1: 달러, 2:유로, 3:엔화, 4:위안, 5:원\n");
System.out.print("▶ 원하시는 화폐를 선택해주세요. : ");
int nums = sc.nextInt();
int Krwon; // 한국돈
switch(nums)
{
case 1: //원화 -> 달러 환전시
System.out.print("▶ 바꿀 원화금액을 입력하세요 : ");
Krwon = sc.nextInt();
System.out.printf("환전될 금액은 %.2f 달러입니다.\n",(double)Krwon/Ratedollar);
for (i=0; i<acArray.length; i++)
{
if(acArray[i].getaccountNumber().equals(pAccountNum) && acArray[i].getpassword().equals(ppw)) // 계좌번호 일치 O 『and』 비밀번호 일치 O
{
System.out.println("계좌번호, 비밀번호 일치O");
System.out.println();
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
// int a;
a-=Krwon;
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() -= Krwon;
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
} // case1 end
break;
case 2: //원화 -> 유로 환전시
System.out.print("▶ 바꿀 원화금액을 입력하세요 : ");
Krwon = sc.nextInt();
System.out.printf("환전될 금액은 %.2f 유로입니다.\n",(double)Krwon/RateEuro);
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a -= Krwon;
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() -= Krwon;
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
} // case2 end
break;
case 3: //원화 -> 엔화 환전시
System.out.print("▶ 바꿀 원화금액을 입력하세요 : ");
Krwon = sc.nextInt();
System.out.printf("환전될 금액은 %.2f 엔화입니다.\n",(double)Krwon/RateEnhwa);
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a-=Krwon;
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() -= Krwon;
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
} // case3 end
break;
case 4: //원화 -> 위안 환전시
System.out.print("▶ 바꿀 원화금액을 입력하세요 : ");
Krwon = sc.nextInt();
System.out.printf("환전될 금액은 %.2f 위안입니다.\n",(double)Krwon/RateWean);
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a -= Krwon;
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() -= Krwon;
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
} // case4 end
break;
case 5: //외국 돈 -> 한국돈으로 바꿀때!!!!
System.out.print("갖고계신 화폐 종류를 입력하세요 : 1: 달러, 2:유로, 3:엔화, 4:위안 \n");
System.out.print("▶ 원하시는 화폐를 선택해주세요. : ");
int nums1 = sc.nextInt();
switch(nums1)
{
case 1: //달러->원 으로 바꿀때
System.out.print("▶ 갖고계신 달러금액을 입력하세요 : ");
double ac1 = sc.nextDouble();
System.out.printf("환전될 금액은 %s 원입니다.\n",(int)(ac1 * Ratedollar));
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a+=(int)(ac1 * Ratedollar);
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() += (int)(ac1 * 1200);
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
}// case5 시 그안에 있는 case1일 때 --> 외국돈을 한국돈으로 환전시 외국돈==달러일때
break;
case 2: //유로->원 으로 바꿀때
System.out.print("▶ 갖고계신 유로금액을 입력하세요 : ");
double ac2 = sc.nextDouble();
System.out.printf("환전될 금액은 %s 원입니다.\n",(int)(ac2 * RateEuro));
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a += (int)(ac2 * RateEuro);
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() += (int)(ac2 * 2200);
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
}// case5 시 그안에 있는 case1일 때 --> 외국돈을 한국돈으로 환전시 외국돈==유로일때
break;
case 3: //엔화->원 으로 바꿀때
System.out.print("▶ 갖고계신 엔화금액을 입력하세요 : ");
double ac3 = sc.nextDouble();
System.out.printf("환전될 금액은 %s 원입니다.\n",(int)(ac3 * RateEnhwa));
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a += (int)(ac3 * RateEnhwa);
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() += (int)(ac3 * 1120);
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
}// case5 시 그안에 있는 case1일 때 --> 외국돈을 한국돈으로 환전시 외국돈==엔화일때
break;
case 4: //위안->원 으로 바꿀때
System.out.print("▶ 갖고계신 위안금액을 입력하세요 : ");
double ac4 = sc.nextDouble();
System.out.printf("환전될 금액은 %s 원입니다.\n",(int)(ac4 * RateWean));
for (i=0; i<acArray.length; i++)
{
if ((acArray[i].getaccountNumber().equals(pAccountNum))&&(acArray[i].getpassword().equals(ppw))) // 계좌번호, 비밀번호가 일치하면
{
System.out.println("===============================================");
System.out.println(" 【성함】 : " + acArray[i].getname() + "\t" + acArray[i].getaccountNumber() + " 님의 계좌입니다.");
//int a;
a+= (int)(ac4 * RateWean);
acArray[i].setaccountBalance(a);
//acArray[i].getaccountBalance() += (int)(ac4 * 1080);
System.out.println(" 환전 후 금액 : " + acArray[i].getaccountBalance());
System.out.println();
break;
}
}// case5 시 그안에 있는 case1일 때 --> 외국돈을 한국돈으로 환전시 외국돈==위안일때