Question: QUESTION 8 Given the following code: public class Account private double balance; // instance variable that stores the balance // constructor public Account( double initialBalance)

QUESTION 8 Given the following code: public class Account private double balance; // instance variable that stores the balance // constructor public Account( double initialBalance) 17 validate that initialBalance is greater than 0.@: // if it is not, balance is initialized to the default value 0.0 if ( initialBalance > 0.03 balance = initialBalance: } // end Account constructor 1/ credit (add) an amount to the account public void credit double amount balance = balance + amount; // add amount to balance } 11 end method credit 17 return the account balance public double setBalance) return balance: 1) rives the value of balance to the calling method I end method setBalance end class Account 1/ end method.setBalance 2/7 end class Account What is output by the following main method? public static void main(String args[] { Account account1 = new Account(15.33) System.out.printf("accounti balance: $%.2f ". accounti. RetBalance()); System.out.println("adding $2.53 to account balance"); accounti.credite 2.53 ); System.out.printf(account balance.2f ", accounti.getBalance(); D // end main account balance: 15.33 O adding 2.53 to account balance account balance: 17.86 account balance: $15.33 adding 52 53 to account balance account balance: $17 86 account balance: $15.33 adding $17 86 to account balance account balance $2.53 Click Save and submit to save and submit Clio Save As to sore all enters Joe (1) EN
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
