If you were me and creating an ATM simulation program, what would you check first if the user have entered the amount he/she is going to widthdraw? The balance or the money in the machine (ATM)? What I did is to check the balance first before money inside the ATM. Yes, it works but what do you think is most right one? I'm just want to improve my logic in programming :)
I don't think there's a compelling reason to consider one of them right and the other wrong.
I suppose if I was the user trying to withdraw money, it would be more useful to know whether I had run out funds in my account than it would be to know whether the machine is out of cash, so that might be the better of the two to check first.
Well, that would be done after the user has confirmed their credentials and specified the amount they want to withdraw, but before the machine actually attempts to dispense cash. After all, you can't have the ATM whirring its motors and thinking it's given out $100, charging it to the user's account, if there isn't actually any money left in the machine.
Edit: On second thoughts, checking the balance of money in the machine could be something that's done after the previous withdrawal. If there's no cash left - or maybe if the cash reserve has fallen below some defined threshold - the ATM should simply refuse to allow the user to even select "Withdraw cash".