Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class (with a main method) called AppleTest Declare 2 double variables n

ID: 3581314 • Letter: W

Question

Write a class (with a main method) called AppleTest Declare 2 double variables named: interest Amount and new Balance Declare an object of the above class AppieAccount called "account" and initialize t with the following data: Larry, 50000, 0. 10 Call the appropriate method to calculate the interest amount of the "account1" object and assign it to the variable "interestAmount". Add the interestAmount variable (above) to the current balance of the "account1" object and assign the result to the variable 'newBalance'. Use the 'newBalance' variable (above) ti set the new account balance of the 'account1' object. Declare a new object of the AppleAccount class called "account2" and initialize it with following data George, 100000, 0.06. Compare the balances of the 'account1" and 'account2' and print the smallest balance.

Explanation / Answer

Java Code:

/* Class definition */
class AppleTest
{
   //Main method
   public static void main(String args[])
   {
       double interestAmount, newBalance;
      
       //Creating an object of AppleAccount class
       AppleAccount account1 = new AppleAccount("Larry", 50000, 0.10);
      
       //Calculating interest amount
       interestAmount = account1.calculateInterest();
      
       //Updating new balance
       newBalance = interestAmount + account1.getCurrentBalance();
      
       //Updating new balance
       account1.setCurrentBalance(newBalance);
      
       //Creating another object of class AppleAccount
       AppleAccount account2 = new AppleAccount("George", 100000, 0.06);
      
       //Comparing balance of both accounts
       if(account1.getCurrentBalance() < account2.getCurrentBalance())
       {
           //Printing account with lowest balance
           System.out.println(account1.getName() + " has lowest balance ");
       }
       else
       {
           System.out.println(account2.getName() + " has lowest balance ");
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote