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

Write a class with methods to help you balance your checking account(an object c

ID: 3758677 • Letter: W

Question

Write a class with methods to help you balance your checking account(an object class-main method is not in this class). The CheckingAccount Class should have at least two instance variables: the balance and the total service charges, along with methods to get and set each instance variable.  You may add other variables and methods if you like. The program should read the initial balance for the month, followed by a series of transactions.  For each transaction entered, the program should display the transaction data, the current balance for the account, and the total service charges.  Service charges are $0.10 for a deposit and $0.15 for a check.  If a check forces the balance to drop below $500.00 at any point during the month, a service charge of $5.00 is assessed but only for the first time this happens. Anytime the balance drops below $50.00, the program should print a warning message.  If a check results in a negative balance, an additional service charge of $10.00 should be assessed.  A transaction takes the form of an int number( the transaction code), followed by a double number(the transaction amount).  If the int number is a 1, then the double number is the amount of a check.  If the int number is 2, then the double number is the amount of a deposit.  The last transaction is 0 with no number to follow it. Use the JOptionPane to produce the dialog. A sample Input/Output dialogue is provided via the Sample Run Link below.  Use proper style and indentation, efficient programming techniques and meaningful variable and method names according to Java conventions.

it has to look like this:

public class Main

{

   //global variables:

   //define a CheckingAccount object to keep trach of the

   // account information.

   public static void main (String[] args)

   {

       // defines local variables

       //  get initial balance from the user

       //  perform in a loop until the trans code = 0

       //    get the trans code from the user

             and process it with appropriate helper method

      //   When loop ends show final balance to user.

   }

  

   public static __________ getTransCode()

   {

   }

   public static _________ getTransAmt()

   {

   }

   public static __________ processCheck(___________)

   {

   }

   public static __________ processDeposit(___________)

   {

   }

}

--------------------CheckingAccount.java -------------------------

public class CheckingAccount

{

      private double balance;

      private double totalServiceCharge;

      public CheckingAccount(double initialBalance)

      {

            balance = ______________________;

            totalServiceCharge = ______________;

      }

      public ____________ getBalance()

      {

            return _______________;

      }

      public void setBalance(double transAmt, int tCode)

      {

            if(tCode == 1)

            balance = ___________________;

            else //if(tCode == 2)

                balance = ______________________;

      }

      public ____________ getServiceCharge()

      {

            return totalServiceCharge;

      }

        public void setServiceCharge(double currentServiceCharge)

      {

            totalServiceCharge = ___________________________;

      }

}

Explanation / Answer

public class CheckingAccount
{

private double balance;
private double totalServiceCharge;

public CheckingAccount(double initialBalance)
{
balance = initialBalance;
totalServiceCharge = initialBalance*.10;
}

public double getBalance()
{
return balance - totalServiceCharge;
}

public void setBalance(double transAmt, int tCode)
{
if(tCode == 1){
               balance = balance + transAmt ;
               totalServiceCharge = balance*.15;
           }
else //if(tCode == 2){
               balance = balance + transAmt;
               totalServiceCharge = balance*.10;
           }
  
}

public double getServiceCharge()
{
return totalServiceCharge;
}

public void setServiceCharge(double currentServiceCharge)
{
totalServiceCharge = currentServiceCharge;
}
}

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