You have been tasked to create a class called Abaaneke, your class should contain four private variables (customerName , deposit, oldBalance, newBalace) using the appropriate data types.
Your class should also have a method that takes three arguments – name of account holder, amount deposited and old balance. The method should add the deposit to the oldBalance and call it new balance.
Using the right setters and getters, initialize the private variables and call the method to display the following
a. Account holders name
b. Amount deposited
c. Old balance
d. And new balance
The user should be able to repeat the running of the program as many as he/she wishes
(Kindly write a full Java program)
public class Abaaneke {
private String customerName;
private double deposit;
private double oldBalance;
private double newBalance;
public void transaction(String name, double amountDeposited, double oldBalance) {
newBalance = oldBalance + amountDeposited;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public double getDeposit() {
return deposit;
}
public void setDeposit(double deposit) {
this.deposit = deposit;
}
public double getOldBalance() {
return oldBalance;
}
public void setOldBalance(double oldBalance) {
this.oldBalance = oldBalance;
}
public double getNewBalance() {
return newBalance;
}
public void setNewBalance(double newBalance) {
this.newBalance = newBalance;
}
@Override
public String toString() {
return customerName + " " + deposit + " " + oldBalance + " " + newBalance;
}
}
Comments
Leave a comment