First Java Code Class


public class BankAccount {
String name;
String id;
float balance;

public BankAccount(String a, String i, float tk)
{
name = a;
id = i;
balance = tk;
}

public void deposit(float depAmount)
{
balance = balance + depAmount;
}

public void withdraw(float withAmount)
{
if(balance > withAmount)
{
balance = balance - withAmount;
}
}

public float getBalance()
{
return balance;
}

public void display()
{
System.out.printf("\nName : %s\n ID : %s\n Balance : %.2f", name, id, balance);
}
}

Comments