Declare 2 double variables named interest Amount and new Balance Declare an obje
ID: 3581338 • Letter: D
Question
Declare 2 double variables named interest Amount and new Balance Declare an object of the above class CityAccount called "account" and initialize it with the following data: Larry 30000, 0.15. Call the appropriate method to calculate the interest amount of the 'account" object and assign it to the variable interstAmount Add the interestAmount variable (above) to the current balance of the 'account1" and assign the result to the variable newBalance. Use the newBalance variable (above) to set the new accountbalance of the account1 object. Declare a new object of the CityAccount class called 'accour2' and initialized it with following data Loins. 100000.0.04. Compare balances of the account1' and account2' and print the smallest balance.Explanation / Answer
1.
double interestAmount;
double newBalance;
2.
CitiAccount account1 = new CitiAccount("Larry", 30000, 0.15);
3.
interestAmount = account1.getInterest();
4.
newBalance = account1.getBalance() + interestAmount;
5.
account1.setBalance(newBalance);
6.
CitiAccount account2 = new CitiAccount("Louis", 100000, 0.04);
if account1.getBalance()<account2.getBalance(){
System.out.println(account1.getBalance());
}
else{
System.out.println(account2.getBalance());
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.