BankAccount Class

class BankAccount
{

double balance; // instance field
string name; // instace field
static double interest; // static field

public BankAccount() : this(1000, “HCI”) // default constructor
{
}

public BankAccount(double balance, string name) // constructor
{

this.balance = balance;
this.name = name;
BankAccount.interest = 0.7; // 0.7%

}

public void Deposit(double amount) // instance method
{

balance += amount;

}

public void Withdrawal(double amount) // instance method
{

balance -= amount;

}

public void Print() // instance method
{

double currentBalance = balance + balance * BankAccount.interest * 0.01;

Console.WriteLine(“{0}의 계좌 잔고는 {1}”, name, currentBalance);

}

public static void SetInterestRate(double interest) // static method
{

BankAccount.interest = interest;

}

}

 

class Program
{

static void Main(string[] args)
{

BankAccount b = new BankAccount(5000, “HCI222222222222”);
b.Print();

b.Deposit(1000);
b.Print();

b.Withdrawal(500);
b.Print();

BankAccount.SetInterestRate(1.5); // 1.5%
b.Print();

BankAccount b2 = new BankAccount();
b2.Print();

}

}