At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Ask your questions and receive detailed answers from professionals with extensive experience in various fields. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.
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;
}
}
}
![View image sandlee09](https://us-static.z-dn.net/files/d49/d5243d3b528f0982815e8c02411ce2af.jpg)
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;
}
}
}
Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.