3초기억력

클래스 : 계좌번호, 잔액 - 클래스 생성, 기능 - 입금, 출금, 잔액조회 본문

자바_기초

클래스 : 계좌번호, 잔액 - 클래스 생성, 기능 - 입금, 출금, 잔액조회

잠수콩 2019. 5. 21. 16:06
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
//계좌번호, 잔액 - 클래스 생성
// 기능 - 입금, 출금, 잔액조회

package Class;

class Account{
	
	String acc_Number;
	int money;
	
	//기능 - 입금
	void deposit(int a) {
		money = money + a;
		System.out.println("입금액 : "+ a);
	}
	
	int search(String a) {
		
		return money;
	}
	
	//기능 - 출금 후 잔액조회
	void withdraw(int a) {
		money = money - a;
		System.out.println("출금액 : "+ a);
	}
	
}

public class ClassEx_1 {

	public static void main(String[] args) {

		//계좌 생성
		Account a1 = new Account();
		a1.acc_Number = "111-222-333-444";
		a1.money = 1000;

		//조회
		int b1 = a1.search("111-222-333-444");		
		System.out.println("잔액조회 : "+b1);
		
		//2000원 입금
		a1.deposit(2000);
		
		//조회
		int b2 = a1.search("111-222-333-444");		
		System.out.println("잔액조회 : "+b2);
		
		//출금
		a1.withdraw(3000);

		//조회
		int b3 = a1.search("111-222-333-444");		
		System.out.println("잔액조회 : "+b3);

	}

}
Comments