Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Join our Q&A platform and connect with professionals ready to provide precise answers to your questions in various areas. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
Sagot :
Answer:
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;
}
}
}
Answer:
public class BankAccount {
private String customerName;
private double savingsBalance;
private double checkingsBalance;
public BankAccount(String newName, double amt1, double amt2) {
this.customerName = newName;
this.checkingsBalance = amt1;
this.savingsBalance = amt2;
}
public void setName(String newName) {
this.customerName = customerName;
}
public String getName() {
return customerName;
}
public void setChecking(double checkingsBalance) {
this.checkingsBalance = checkingsBalance;
}
public double getChecking() {
return checkingsBalance;
}
public void setSavings(double savingsBalance) {
this.savingsBalance = savingsBalance;
}
public double getSavings() {
return savingsBalance;
}
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;
}
}
}
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.