import java.util.Scanner;
public class AccountFrame
{
public static void main(String args[])
{
Account account1 = new Account (50.00);
Account account2 = new Account(-7.53);
System.out.printf("account1 balance:$%.2fn".account1.getBalance());
System.out.printf("account2 balance:$
%.2fnn".account2.getBalance());
Scanner input= new Scanner(System.in);
double depositAmount;
System.out.printf("enter deposit amount for account1:");
depositAmount = input.nextDouble();
System.out.printf("nadding %.2f to account1
balancenn".depositAmount);
account1.credit(depositAmount);
System.out.printf("account1 balance: $
%.2fn".account1.getBalance());
System.out.printf("account2 balance: $
%.2fnn".account2.getBalance());
System.out.printf("enter deposit amount for account2:");
depositAmount =input.nextDouble();
System.out.printf("nadding %.2f to account2
balancenn".depositAmount);
account2.credit(depositAmount);
System.out.printf("account1 balance: $
%.2fn".account1.getBalance());
System.out.printf("account2 balance: $
%.2fn".account2.getBalance());
}
}

Jva

  • 1.
    import java.util.Scanner; public classAccountFrame { public static void main(String args[]) { Account account1 = new Account (50.00); Account account2 = new Account(-7.53); System.out.printf("account1 balance:$%.2fn".account1.getBalance()); System.out.printf("account2 balance:$ %.2fnn".account2.getBalance()); Scanner input= new Scanner(System.in); double depositAmount; System.out.printf("enter deposit amount for account1:"); depositAmount = input.nextDouble(); System.out.printf("nadding %.2f to account1 balancenn".depositAmount); account1.credit(depositAmount); System.out.printf("account1 balance: $ %.2fn".account1.getBalance()); System.out.printf("account2 balance: $ %.2fnn".account2.getBalance()); System.out.printf("enter deposit amount for account2:"); depositAmount =input.nextDouble(); System.out.printf("nadding %.2f to account2 balancenn".depositAmount); account2.credit(depositAmount); System.out.printf("account1 balance: $ %.2fn".account1.getBalance()); System.out.printf("account2 balance: $ %.2fn".account2.getBalance()); } }