Commit 6cf0a9c5 authored by jose.alencastro's avatar jose.alencastro

ok

parent 8b4bd3eb
public class SavingsAccount
{
// bank account attributes
static int accountNumber;
static String name;
double balance;
// contructor method
public SavingsAccount()
{
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;
}
else
{
System.out.print("Insufficient Funds");
}
}
// 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);
}
// interest method
public int accrueInterest()
{
int interest = (int) (balance * .05);
balance = balance + interest;
return (int) balance;
}
public static void main(String[] args)
{
SavingsAccount bensAccount = new SavingsAccount();
bensAccount.deposit(200);
bensAccount.withdraw(50);
bensAccount.accrueInterest();
bensAccount.bankFee();
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