Create class Bank with the member variable acc_num and amount. It has the method deposite() to credit the amount and withdraw() to debit the amount from the account. - Pratik Ghelani

Pratik Ghelani

Breaking

Saturday, March 23, 2019

Create class Bank with the member variable acc_num and amount. It has the method deposite() to credit the amount and withdraw() to debit the amount from the account.

Program

public class Main
{
long acc_num;
float amount = 0;


void deposite(float f)
  {
amount = amount + f;
}
void Withdraw(float f)
  {
if (f > amount)
{
System.out.println("limited");
}
else
{
amount = amount - f;
}
}

public static void main(String args[])
{
Main b = new Main();
b.deposite(5000);
b.Withdraw(500);
System.out.println("your balance =" + b.amount);
}
}



No comments:

Post a Comment