... account1.getBalance());
13         System.out.printf("%s balance: $%.2f%n%n",
14            account2.getName(), account2.getBalance());
15
16         // create a Scanner to obtain input from the command window
17         Scanner input = new Scanner(System.in);
18
19         System.out.print("Enter deposit amount for account1: "); // prompt
20         double depositAmount = input.nextDouble(); // obtain user input
21         System.out.printf("%nadding %.2f to account1 balance%n%n",
22            depositAmount);
23         account1.deposit(depositAmount); // add to account1’s balance
24
25         // display balances
26         System.out.printf("%s balance: $%.2f%n",
27            account1.getName(), account1.getBalance());
28         System.out.printf("%s balance: $%.2f%n%n",
29            account2.getName(), account2.getBalance());
30
31         System.out.print("Enter deposit ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.