Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago