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
package abaaneke;
public class Abaaneke {
private double deposit, oldBalance, newBalace;
private String customerName ;
void details(String name, double de, double old){
deposit = de;
oldBalance = old;
customerName = name;
newBalace = deposit + oldBalance;
System.out.printf("Customer Name:"
+ " %s\nAmount deposited: %f\n Old balance:"
+ " %f\nNew balance %f ", customerName, deposit,oldBalance,newBalace);
}
void setCustomerName (String n){
customerName = n;
}
void setDeposit (double n){
deposit = n;
}
void setOldBalance (double n){
oldBalance = n;
}
double getOld(){
return oldBalance;
}
double getNew(){
return newBalace;
}
double getDeposit(){
return oldBalance;
}
String getName(){
return customerName;
}
public static void main(String[] args) {
Abaaneke a = new Abaaneke();
}
}
Comments
Leave a comment