은행 입출금 관리 프로그램 도움요청
해대기
은행입출금 관리 프로그램인데
입금/출금/계좌이체부분을 완성시켜야하는데요.
도움좀 요청합니다.
//계좌를 구현한 클래스
class Account implements Cloneable{// Account 복제본 만드려면 implements Cloneable
//field
private String accountNumber;
private String name;
private String password;
private int balance;
private static int totalBalance; //클래스 변수
//static 변수 초기화
static {
System.out.println(call static initialize block);
totalBalance=0; //Account.totalBalance=0;
}
//Default Constructor method
public Account( ) {
}
//매개변수 Constructor method
public Account(String accountNumber, String name,
String password, int balance) {
System.out.println(call Constructor!!);
this.accountNumber=accountNumber;
this.name=name;
this.password=password;
this.balance=balance;
totalBalance+=balance;
}
//입금하다. : deposit
public void deposit(int amount) { //입금액
if(amount0) {
System.out.println(입금액을 정확히 입력하세요);
return;
}
balance+=amount;
totalBalance+=amount;
}
//잔고를 조회하다. getBalance
public int getBalance( ) {
return balance;
}
//출금하다. withdraw
public void withdraw(int amount) {
if( amount0 ) {
System.out.println(금액을 정확히 입력하세요);
return;
}
if( amountbalance ) {
System.out.println(잔고를 초과하셨습니다.);
return;
}
balance-=amount;
totalBalance-=amount;
}
//계좌의 모든 정보를 조회하다.( getAccountInfo )
public String getAccountInfo( ) {
return AccountNumber=+accountNumber
+, Name=+name
+, Password=+password
+, Balance=+balance;
}
//비밀번호를 변경하다. (setPassword)
public void setPassword(String password) {
this.password=password;
}
//계좌이체하다.
public void transferAccount(Account account, int amount) {
this.withdraw(amount);
account.deposit(amount);
}
//은행 총잔고를 구한다.
public static int getTotalBalance( ) {
return totalBalance;
}
//계좌번호를 구한다.
public String getAccountNumber( ) {
return accountNumber;
}
//예금주명을 조회하다.
public String getName() {
return name;
}
//예금주명을 변경하다.
public void setName(String name) {
this.name=name;
}
//비밀번호를 조회하다.
public String getPassword( ) {
return password;
}
//Method overriding
public String toString() {
return AccountNumber=+accountNumber
+, Name=+name
+, Password=+password
+, Balance=+balance;
}
//Method overriding
public boolean equals(Object obj) {
if(!(obj instanceof Account)) {
return false;
}
Account temp=(Account)obj;
if( this.accountNumber.equals(temp.accountNumber) ) {
return true;
}
return false;
}
//native method
protected Account clone()
throws CloneNotSupportedException{
return (Account)super.clone();
}
}
import java.util.*;
public class AccountManager {
static Account[] accounts=new Account[100];
static int index=0;
//계좌번호 존재 유무를 체크한다.
public static Account checkAccountNumber( String accountNumber){//리턴유형 Account
for (int i=0; iindex ;i++ ){
String temp=accounts[i].getAccountNumber();
if (temp.equals(accountNumber)){
Account account=accounts[i];
return account;
}
}
return null;
}
//잔액 조회하다.
public static void retrieveBalance( ) {
Scanner scan=new Scanner(System.in);
System.out.print(계좌번호 : );
String accountNumber=scan.nextLine( ); //2
Account account=checkAccountNumber(accountNumber);
if(account==null){
System.out.printf(%s 계좌번호가 존재하지 않습니다., accountNumber);
return;
}
System.out.print(비밀번호 : );
String password=scan.nextLine( );
String temp=account.getPassword( );
if(password.equals(temp)) {
int balance=account.getBalance( );
System.out.printf(Balance=%d%n, balance);
}
else {
System.out.printf(%s 비밀번호가 존재하지 않습니다.,
password);
}
}
//계좌개설하다.
public static void createAccount( ) {
Scanner scan=new Scanner(System.in);
System.out.print(계좌번호 : );
String accountNumber=scan.nextLine( );
System.out.print(예금주명 : );
String name=scan.nextLine( );
System.out.print(비밀번호 : );
String password=scan.nextLine( );
System.out.print(잔고 : );
int balance=scan.nextInt( );
/*
Account account=new Account(accountNumber,
name, password, balance);
accounts[index]=account;
*/
accounts[index]=
new Account(accountNumber, name, password, balance);
index++;
}
//입금
//출금
//계좌이체
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
boolean isExit=false;
do
{
System.out.println(===== 은행 입출금 관리 시스템 =====);
System.out.println(1. 계좌개설);
System.out.println(2. 입금 );
System.out.println(3. 출금);
System.out.println(4. 잔액조회);
System.out.println(5. 계좌이체);
System.out.println(6. 종료);
System.out.print(메뉴를 선택하세요 );
int menu=scan.nextInt( );
switch(menu) {
case 1:
//계좌개설
createAccount( );
break;br /ak;
case 2:
//입금
break;
case 3:
//출금
break;
case 4:
//잔액조회
retrieveBalance( );
break;
case 5:
//계좌이체
break;
case 6:
//종료
isExit=true;
break;
}
}
while ( !isExit );
}
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700452 | c언어에서... 자료형 구분.... (3) | 시내 | 2025-07-05 |
2700422 | 버전에 관해 질문 | 라온제나 | 2025-07-04 |
2700393 | mysql이 갑자기!!!!!!!!!!!!!!!에러가;; (2) | 소미 | 2025-07-04 |
2700359 | 3.0 ) SimpleButton 상태 강제 변경 (3) | 희선 | 2025-07-04 |
2700304 | ie8 전용핵 문의 (3) | 여자 | 2025-07-03 |
2700281 | 이런경우 어떻게 코딩해야 표준에 따르는건가요? (6) | 늘솜 | 2025-07-03 |
2700230 | 질문이여 ! | 뿡뿡몬 | 2025-07-03 |
2700205 | 액션스크립트책 좀 추천해주세요. (10) | 화이트캣 | 2025-07-02 |
2700173 | 자바 소스인데 어떤게 에러인지..? (1) | 호빵녀 | 2025-07-02 |
2700142 | 하단이 붙어있는 가변 레이아웃구조 질문드립니다. | 이플 | 2025-07-02 |
2700089 | 이미지를 사다리꼴로 비틀게 하는 액션코드가 있나요? (4) | 여름 | 2025-07-01 |
2700033 | 배경에 그라데이션을 넣으려고 하는데요.. (4) | 화이티 | 2025-07-01 |
2700005 | [질문] TextField 객체의 실제 높이 알아오는 방법 ? | 천사의눈물 | 2025-07-01 |
2699978 | FileReferenceList를 이용하여 업로드시 자꾸 실행속도가 느리다는 팝업이... (10) | 데이비드 | 2025-06-30 |
2699944 | 자바스크립트가 많은 사이트는... (6) | 희나리 | 2025-06-30 |
2699918 | 브라우저마다 다른 input과 텍스트 정렬 (3) | 늘봄 | 2025-06-30 |
2699887 | 동적텍스트를 그래픽으로?? (2) | 족장 | 2025-06-30 |
2699862 | scope넣기 (1) | 아인 | 2025-06-29 |
2699835 | exe로 만드는 방법을....알려주세요.. (5) | 방방 | 2025-06-29 |
2699809 | 롤오버할때 백그라운드 이미지로할때 alt설명은 어떻게해야하죠?..ㅠ (4) | 반혈 | 2025-06-29 |