I just have a small beginners question, and it’s about the code below. I want to check if the amount that the customer deduct from a credit account + the current balance don’t getting lower than -5000 ? It’s not working, and I’m wondering what I have done wrong? Is it about negative values? Help preciated!
// deduct credit account
if(type == "credit") {
if((amountOut + creditAccountList.get(index).getAccountBalance()) < -5000) {
System.out.println("Sorry! No deduct");
}
}
EDIT:
The amountOut is a positive number that the customer enters. I still don’t get it to work!? Could it be done in some other way? It seems so simple, byt yet so comlicated for me right now! I just want to prevent the customer to deduct a value if the balance is -5000? The problem is that the balance is a negative number.
I think you have to rewrite the condition. If I understood your case is the customer can withdraw an 5000 more than that of diposited amount. Example If customer has balance of 2000rs he/she can withdraw maximum 7000 rupees. If he/she wants to withdraw morw then your application will show “Sorry! No deduct” message. If this is the case then you can re-write the logic as given below