Missing methods to print the account balances
Hello I am reposting this because I wanted to be more discriptive in the title heading. Thanks!
Hello, I am struggling with this assingment. The balance in this code prints 0.0 Why does this happen How can I fix that problem? Then the next part asks me to add println methods to the main function to show that the problem is fixed for all entries made into Mr. Partridge's account. Can anyone assist me with this?? Thanks!!
class User{
private int accountID,routingNum;
private float balance, lastDepositAmount, lastWithdrawalAmount;
private String[] info = new String[9]; //info(0) = First name, info(1) = middle name,
//info(2) = Last Name, info(3) = Street Address,
//info(4) = State, info(5) = Zip Code, info(6) = Tel
//info(7) = email address, info(8) = Description
private String creationDate,terminationDate;
private String lastDepositDate, lastWithdrawalDate;
static void getBalance(User user){System.out.println(user.balance);}
static void getCreationDate(User user){System.out.println(user.creationDate);}
static void setCreationDate(User user, String date){user.creationDate = date;}
static void setTerminationDate(User user, String date){user.terminationDate = date;}
static void getTerminationDate(User user){System.out.println(user.terminationDate);}
static void setInfo(User user, String... input){
for(int i=0;i<input.length;i++){user.info[i] = input[i];}
//for(int i=0;i<input.length;i++){System.out.println(input[i]);}
}
static void getInfo(User user){
for(int i=0;i<user.info.length;i++){
System.out.println(user.info[i]);
}
}
static void setDeposit(User user, float deposit,String date){user.balance+= deposit;user.lastDepositAmount = deposit;user.lastDepositDate = date;}
static void setWithdrawal(User user,float withdrawal,String date){
if(withdrawal > user.balance){
System.out.println("Withdrawal amount exceeds balance.");
}
else{
user.balance-= withdrawal; user.lastWithdrawalAmount = withdrawal;
user.lastWithdrawalDate = date;
}
}
static void setAccountID(User user, int accountNum){user.accountID = accountNum;}
static void getAccountID(User user){System.out.println(user.accountID);}
static void setRoutingNum(User user, int routing){user.routingNum = routing;}
static void getRoutingNum(User user){System.out.println(user.routingNum);}
static void getLastDeposit(User user){System.out.println("Date of Deposit: "+user.lastDepositDate + " Amount "+ user.lastDepositAmount);}
static void getLastWithdrawal(User user){System.out.println("Date of Withdrawal "+user.lastWithdrawalDate+" Amount "+user.lastWithdrawalAmount);}
}
class c3p4{
public static void main(String[] args){
User user1 = new User();
createAccount();
user1.getBalance(user1);
}
static void createAccount(){
User user1 = new User();
User.setAccountID(user1, 1234567);
User.setRoutingNum(user1, 9872345);
User.setInfo(user1,"John","C","Partridge","123 Liberty Way","VA","24502","555-3456","jcpartri@liberty.edu","This is a new account holder.");
User.setDeposit(user1, 500.00f,"01/01/2010");
User.setCreationDate(user1, "01/01/2010");
}
}
Re: Missing methods to print the account balances
Reposting the question and ignore the responses in the previous question is no way to motivate others to help you. Consider improving your previous question. Locking.
Edit: and the hints towards the solution were given in one of the answers too! Again, please read all the links that Darryl provided as they will help you in asking questions here and again, please reply to the answers already given in your previous post. If you don't understand any of the points in either reply, please ask for clarification, but please out of fairness to the volunteers here, don't just ignore the replies.