목록으로 2013.03.18. 19:44
C언어

저축예금 클래스 VER.3

youtube

BankAccount ver_3.JPG

BankAccount ver_3.cpp

 

#include <iostream>
#include <string>
using namespace std;

class BankAccount
{
private:
        string name;
        int balance;
        int rate;
 
public:
        BankAccount(string n){name = n; balance=1000; rate=5;}
        void deposit(int money);
        void withdraw(int money);
        void print();
};

void BankAccount::deposit(int money)
{
 cout << "입금액 "  << money<<endl;
 balance = balance + money;
 cout<< "잔고 " << balance<<endl;

}
void BankAccount::withdraw(int money)
{
 cout << "출금액 "  << money<<endl;
 balance = balance - money;
 cout<< "잔고 " << balance<<endl;
 if (balance <money)
  cout << "출금액 "<< money<<"이 잔고"<<balance<<"보다 많아 출금 불가능!!"<<endl;
}
void BankAccount::print()
{cout << "예금주 : " << name <<  endl << "예금액 : " << balance << "원" << endl << "이율 : " << rate << "%" << endl;}

void main()
{
        BankAccount ba("강봄");
        ba.print();
  ba.deposit(5000);
  ba.withdraw(4000);
}

댓글 0

댓글 작성 권한이 없습니다. 로그인하기

NO
TITLE
섬네일
sd | 05. 30 | 조회
67
레이나sv | 05. 05 | 조회
66
profile 너에게제공 | 04. 10 | 조회
58
profile 너에게제공 | 04. 10 | 조회
57
C언어
profile 너에게제공 | 04. 10 | 조회
56
C언어 예제1
C언어
profile 너에게제공 | 04. 02 | 조회
55
C언어 BMI
profile 너에게제공 | 04. 02 | 조회
54
레이나sv | 04. 02 | 조회
53