At Westonci.ca, we connect you with the answers you need, thanks to our active and informed community. Discover a wealth of knowledge from professionals across various disciplines on our user-friendly Q&A platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
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 your visit. We're committed to providing you with the best information available. Return anytime for more. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.