QUESTION

This exercise comes with a ready-made class named Account. The Account object represents a bank account that has some amount of money in it. The accounts are used as follows:

Account usAccount = new Account("US account", 100.00);

Account chAccount = new Account("Swiss account", 1000000.00);

System.out.println("Intial state");

System.out.println(usAccount);

System.out.println(chAccount);

usAccount.withdraw(20);

System.out.println("The balance of the US account is now: " + usAccount.balance());

chAccount.deposit(200);

System.out.println("The balance of the Swiss account is now: " + chAccount.balance());

System.out.println("Ending balances");System.out.println(usAccount);System.out.println(chAccount);

Write a program in Java that creates an account with a balance of 100.0, deposits 20.0 in it, and finally prints the balance. Perform all the operations in the order given.

Public Answer

CZG4A2 The First Answerer