Q:

How to return and set to zero?

I want to ask one question. If the amount is greater than the balance than I have to return the whole balance and set the balance to zero.. How can I do that? I have tried many different ways to solve this but it didn't work. Thanks for your help.
public class BankAccount {
    double balance;

    BankAccount(double openingBalance){
        balance=openingBalance;
    }
        public double getBalance(){
        return balance; 
    }
    public void deposit(double amount){
        balance += amount;
    }
    public double withdraw (double amount){ 
        if (balance > amount){
            balance -= amount;
        }else if (amount > balance || amount == balance){       
            **return balance; 
            balance = 0**
        }   
        return amount;
    }
}

Driver class 
public class Driver {

    static BankAccount acc3;

    public static void main (String[] args){
        BankAccount  acc3 = new BankAccount ("Alana","Neil", 5000);
        System.out.println("\nName: " +acc3.Name());
        System.out.println("Amount: $" +acc3.balance);
        acc3.deposit(100);
        System.out.println("Deposit Amount: $" +acc3.balance);
        System.out.println("Withdrawl Amount: $"+acc3.withdraw(5400));
        System.out.println("The New Balance: $" +acc3.balance);

    }
}

A:

Use  a temporary variable:
double tmp = balance;
balance = 0;
return tmp;

