You have bank accounts in two banks: Bank1 and Bank2. You deposited 500 to each of the banks and withdrew 100 from each of the banks. Show the remaining balance in each of the banks.
public class BankNetBalance {
public static void main(String[] args) {
Deposit_Withdraw bank1 = new Deposit_Withdraw();
double balance_bank1 = bank1.deposit(500)-bank1.withdraw(100);
System.out.println("BANK1 balance : "+balance_bank1);
Deposit_Withdraw bank2 = new Deposit_Withdraw();
double balance_bank2 = bank2.deposit(500)-bank2.withdraw(100);
System.out.println("Bank2 balance : "+balance_bank2);
}
public double deposit(double depositAmount) {
double balance = 0;
balance = balance+depositAmount;
return balance ;
}
public double withdraw(double withDrawAmount) {
double balance = 0;
balance = balance+withDrawAmount;
return balance ;
}
}
//-----------------------------------------------------------------------------------------------------------
Output:
Bank1 balance : 400.0
Bank2 balance : 400.0
No comments:
Post a Comment