plven the following code ublic class Account { private double balance; / instance variable that stores the balance // constructor public Account( double initialBalance ) H validate that initialBalance is greater than 0.0; // if it is not, balance is initialized to the default value 0.0 if ( initialBalance > 0.0) balance = initialBalance; } // end Account constructor // credit (add) an amount to the account public void credit( double amount ) balance = balance + amount; // add amount to balance } // end method credit // return the account balance public double getBalance() return balance; // gives the value of balance to the calling method } // end, method getBalance } // end class Account Vhat is output by the following main method? public static void main( String args[] ) Account account1 = new Account( 15.33 ); System.out.printf( "account1 balance: $%.2f\n", account1.getBalance() ); System.out.println( "adding $2.53 to account1 balance" ); account1.credit( 2.53 ); System.out.printf( "account1 balance: $%.2f\n", account1.getBalance() ); } // end main O account1 balance: 15.33 adding 2.53 to account1 balance account1 balance: 17.86 O account1 balance: $15.33 adding $2.53 to account1 balance account1 balance: $17.86 Oaccount1 balance: $17.86 adding $15.33 to account1 balance account1 balance: $2.53 O account1 balance: $15.33 adding $17.86 to account1 balance account1 balance: $2.53 Save and Submit to save and submit. Click Save All Answers to save all answers.
plven the following code ublic class Account { private double balance; / instance variable that stores the balance // constructor public Account( double initialBalance ) H validate that initialBalance is greater than 0.0; // if it is not, balance is initialized to the default value 0.0 if ( initialBalance > 0.0) balance = initialBalance; } // end Account constructor // credit (add) an amount to the account public void credit( double amount ) balance = balance + amount; // add amount to balance } // end method credit // return the account balance public double getBalance() return balance; // gives the value of balance to the calling method } // end, method getBalance } // end class Account Vhat is output by the following main method? public static void main( String args[] ) Account account1 = new Account( 15.33 ); System.out.printf( "account1 balance: $%.2f\n", account1.getBalance() ); System.out.println( "adding $2.53 to account1 balance" ); account1.credit( 2.53 ); System.out.printf( "account1 balance: $%.2f\n", account1.getBalance() ); } // end main O account1 balance: 15.33 adding 2.53 to account1 balance account1 balance: 17.86 O account1 balance: $15.33 adding $2.53 to account1 balance account1 balance: $17.86 Oaccount1 balance: $17.86 adding $15.33 to account1 balance account1 balance: $2.53 O account1 balance: $15.33 adding $17.86 to account1 balance account1 balance: $2.53 Save and Submit to save and submit. Click Save All Answers to save all answers.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.2: Basic Class Functions
Problem 5E
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 4 images
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning