Question #27176

i need a code that will calculate available balance on the atm program(own class)
1

Expert's answer

2013-04-17T11:16:07-0400
public class ATM {
//available balance
private static double balance=10000;
//check available balance
public static double checkBalance() {
return balance;
}
//add money to balance
public static void addToBalance(double money) {
ATM.balance = ATM.balance + money;
}
//remove money from balance
public static double removedFromBalance(double money) {
if(ATM.balance-money<=0)
return 0;
else
return ATM.balance-money;
}
//some operation with ATM
public static void main(String[] args) {
System.out.println(checkBalance());
addToBalance(587);
removedFromBalance(50);
System.out.println(checkBalance());
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS