Answer:
Step-by-step explanation:
The following code is written in Java and creates the BankAccount class with all of the requested methods, including the constructor, getter and setter methods, withdraw methods, and even the transferToSavings method. A preview can be seen in the attached image below.
class BankAccount {
private String customerName;
private double savingsBalance, checkingsBalance;
public BankAccount(String newName, double amt1, double amt2) {
this.customerName = newName;
this.checkingsBalance = amt1;
this.savingsBalance = amt2;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public double getSavingsBalance() {
return savingsBalance;
}
public void setSavingsBalance(double savingsBalance) {
this.savingsBalance = savingsBalance;
}
public double getCheckingsBalance() {
return checkingsBalance;
}
public void setCheckingsBalance(double checkingsBalance) {
this.checkingsBalance = checkingsBalance;
}
public void depositChecking(double amt) {
if (amt > 0) {
this.checkingsBalance += amt;
}
}
public void depositSavings(double amt) {
if (amt > 0) {
this.savingsBalance += amt;
}
}
public void withdrawChecking(double amt) {
if (amt > 0) {
this.checkingsBalance -= amt;
}
}
public void withdrawSavings(double amt) {
if (amt > 0) {
this.savingsBalance -= amt;
}
}
public void transferToSavings(double amt) {
if (amt > 0 ) {
this.checkingsBalance -= amt;
this.savingsBalance += amt;
}
}
}