Question: Please convert Java to Python. public class AccountTester { public static void main(String[] args) { SavingsAccount momsSavings = new SavingsAccount(0.5); CheckingAccount harrysChecking = new CheckingAccount(100);

Please convert Java to Python.

public class AccountTester

{

public static void main(String[] args)

{

SavingsAccount momsSavings

= new SavingsAccount(0.5);

CheckingAccount harrysChecking

= new CheckingAccount(100);

momsSavings.deposit(10000);

// Transfer $2000

momsSavings.withdraw(2000);

harrysChecking.deposit(2000);

harrysChecking.withdraw(1500);

harrysChecking.withdraw(80);

// Transfer $1000

momsSavings.withdraw(1000);

harrysChecking.deposit(1000);

harrysChecking.withdraw(400);

// Simulate end of month

momsSavings.addInterest();

harrysChecking.deductFees();

System.out.println("Mom's savings balance = $"

+ momsSavings.getBalance());

System.out.println("Harry's checking balance = $"

+ harrysChecking.getBalance());

// Inheritance TimeDepositAccount

System.out.println("Test with Penalty");

TimeDepositAccount tda1 = new TimeDepositAccount ( 5, 3 );

tda1.deposit(1000);

tda1.addInterest(); //monthly: month 1

tda1.addInterest(); // month 2

System.out.println("Before withdrawal ($500): " + tda1.getBalance());

tda1.withdraw(500);

System.out.println("After withdrawal ($500): " +tda1.getBalance());

System.out.println("Test without Penalty");

TimeDepositAccount tda2 = new TimeDepositAccount ( 5, 3 );

tda2.deposit(1000);

tda2.addInterest(); //monthly: month 1

tda2.addInterest(); // month 2

tda2.addInterest(); // month 3

System.out.println("Before withdrawal ($500): " + tda2.getBalance());

tda2.withdraw(500);

System.out.println("After withdrawal ($500): " +tda2.getBalance());

// Polymorphism, abstract, toString

// BankAccount not = new BankAccount(); // NOTE: cannot instantiate a BankAccount; must be a subclass

BankAccount[] accounts = {momsSavings, harrysChecking, tda1, tda2};

for (int i=0; i < accounts.length; i++)

{

accounts[i].deposit(25);

System.out.println("Account: " + accounts[i]);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!