Commit 8b4bd3eb authored by jose.alencastro's avatar jose.alencastro

ok

parent 341d40bd
public class BankAccount
{
// bank account attributes
static int accountNumber;
static String name;
double balance;
// contructor method
public BankAccount()
{
accountNumber = 12345;
name = "Ben";
balance = 1000;
}
// deposit method
public void deposit(double amount)
{
balance = balance + amount;
}
// withdraw method
public void withdraw(double amount)
{
if (amount <= balance)
{
balance = balance - amount;
// overdraft method
}
else if (amount > balance && balance > -100)
{
System.out.println("Overdraft limit reached.");
balance = -100;
}
}
// bank fee method
public double bankFee()
{
double fee = balance * .05;
balance = balance - fee;
return balance;
}
// display method
public void displayAccountDetails()
{
System.out.println("Account Number: " + accountNumber + "\n");
System.out.println(name + ": $" + balance);
}
public static void main(String[] args)
{
BankAccount bensAccount = new BankAccount();
bensAccount.deposit(200);
bensAccount.bankFee();
bensAccount.withdraw(1300);
bensAccount.displayAccountDetails();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment