← all problems

Update an account balance 🌶️

The variable balance holds the amount in an account, deposit is a deposit being made, and fee is a fee being charged. Write one or two assignment statements in the box that change balance itself: add the deposit to it, and subtract the fee from it. The locked line at the bottom prints the new balance. Your code will be tested with several different amounts.

Main.java — the program frame below is already written; you're only completing the code in the editable box. Your code will be run several times, each with different starting values for the variables at the top.

public class Main {
    public static void main(String[] args) {
        double balance = 100.0;
        double deposit = 50.0;
        double fee = 2.5;
        // ---- write your code below ----
        System.out.println(balance);
    }
}