main
SavingsAccount class
PHP Code:
import bank.SavingsAccount;
public class test {
public static void main (String [] input_data){
SavingsAccount conto = new SavingsAccount(1000,3.45);
System.out.println("saldo = " + conto.get_balance());
conto.deposit(23);
System.out.println("saldo con deposito di 23 = " + conto.get_balance());
conto.withdraw(40);
System.out.println("saldo con withdarw di 40 = " + conto.get_balance());
conto.addInterest();
System.out.println("saldo con interesse = " + conto.get_balance());
}
}
PHP Code:
package bank;
public class SavingsAccount {
////////////// constructor
public SavingsAccount (double in_saldo, double in_interest){
saldo = in_saldo;
interest = in_interest;
}
public void deposit ( double in_deposit){
saldo+=in_deposit;
}
public void withdraw ( double in_withdraw ){
saldo-=in_withdraw;
}
public double get_balance ( ){
return saldo;
}
///////////// aggiungi interesse trimestrale al conto
public void addInterest () {
saldo += (((saldo / 100) * interest)/4);
}
private double saldo;
private double interest;
}