Question: what is the expected output from the following code: import javax.swing.JOptionPane; public class Samba { public static void main ( String [ ] args )
what is the expected output from the following code:
import javax.swing.JOptionPane;
public class Samba {
public static void main ( String [ ] args ) {
BankAccount bank = new BankAccount ( ) ;
String amount = JOptionPane.showInputDialog ( "Enter the statring amount:" ) ; // expect the user enter $20
bank.deposit ( amount ) ;
System.out.println ( "The curent amount is: " + bank . getBalance ( ) ) ;
}
}
public class BankAccount {
private double balance;
public void deposit ( double amount ) {
balance+= amount ;
}
public void withdraw ( double amount ) {
balance+= amount ;
}
public double getBalance ( ) {
return balance ;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
