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

Below is my prgramming for BankAccount and BankAccountTester. It has to take ini

ID: 3533263 • Letter: B

Question

Below is my prgramming for BankAccount and BankAccountTester.

It has to take initial balance from Scanner, amounts (input with Scanner) should be added to balance (if positve) or subtracted (if negative); balanceOverDraft should assess a $10 fee, and there are two sentinels: 8888 and 9999. 8888 causes the balance to be printed out. 9999 causes the monthly fee to be calculated ($10 if balance >= 100 and 10% if less than 100 in balance.

Why won't it run? BELOW IS BANKACCOUNT AND BANKACCOUNTTESTER

Thank you!

/**
* Program to simulate bank account, with balance, deposits, checks, overdraft and monthly fees.
* @author Marsha McClure
*/
public class BankAccount
{
/**
* Define and initialize balance.
*/
private double balance;
private double amount;
private int balanceOverDraft;
private double serviceFee;

/**
   * Construct default BankAccount.
   *
   */
   public BankAccount()
   {
  balance = 0;
amount = 0;
balanceOverDraft = 10;
serviceFee = 0;
   }

   /**
    * Overloaded constructer BankAccount.

    * @param initialBalance
    */
    public BankAccount(double initialBalance, double anAmount)
    {
   balance = initialBalance;
   amount = anAmount;
  }

     /** Method to return balanceOverDraft.
     *
     * @return balanceOverDraft of 10
     *
     */
     public double getOverDraft()
     {
      return balanceOverDraft;
     }

     /** Method to return monthly service fee.
      *
      * return serviceFee
      *
      */
     public double getServiceFee()
     {
       return serviceFee;
     }

     /**
      * If/else to calculate serviceFee.
      *
      */
      {
    if (balance >= 100)
    {
     serviceFee = 10;
     balance = balance - serviceFee;
    }
    else
     serviceFee = .1 * balance;
     balance = balance - serviceFee;


   }
      /** Method to return balance.
    *
    * @return balance
    *
    */
   public double getBalance()
   {
    return balance;
      }

}

import java.util.Scanner;

/**
* Program to run BankAccount.
* @author Marsha McClure
*/
public class BankAccountTester
{
int balanceOverDraft = 10;

/**
* @param args
*/
public static void main(String[] args)
{
/**
* Construct Scanner for input; input initialBalance.
*
*/
Scanner scan = new Scanner(System.in);

System.out.print("Enter the initial balance: ");
double balance = scan.nextDouble();

System.out.print("Enter the amount to be added or subtracted from the account: ");
double amount = scan.nextDouble();

/**
   * Construct specific bank account.
   *
   */
   BankAccount account = new BankAccount(balance, amount);

/**
   * While loop for sentinel numbers 8888 and 9999.
   *
   */
   while(!(amount == 8888 && amount == 9999))
   {
   if (amount >= 0)
   balance = balance + amount;

    {
    if(amount < 0 && amount < balance)
    balance = balance - amount;

    else
   System.out.println("Your overDraft fee is: " + account.getOverDraft);
   balance = balance - 10;
    }

}

  if(amount == 8888)

   System.out.println("The current balance is: " + account.getBalance);
  }

{
if(amount == 9999 && balance >= 100)

  System.out.println("Your monthly service fee is: " + account.getServiceFee);
  balance = balance - serviceFee;
  }
  {
if(amount == 9999 && balance < 100)
  System.out.println("Your monthly service fee is: " + account.getServiceFee);
  balance = balance - .1 * balance;
  }

}


Explanation / Answer

import java.util.Scanner;

public class BankAccount
{

    private double balance;
    private double amount;
    private int balanceOverDraft;
    private double serviceFee;



    public BankAccount()
    {
        balance = 0;
        amount = 0;
        balanceOverDraft = 10;
        serviceFee = 0;
    }


    public BankAccount(double initialBalance, double anAmount)
    {
        balance = initialBalance;
        amount = anAmount;
        balanceOverDraft = 10;
    }


    public double getOverDraft()
    {
        return balanceOverDraft;
    }

    public double getServiceFee()
    {
        if (balance >= 100)
            serviceFee = 10;
        else
            serviceFee = .1 * balance;
        return serviceFee;
    }


    public double getBalance()
    {

        balance = balance - serviceFee;
        return balance;
    }

}

public class BankAccountTester
{
    int balanceOverDraft = 10;


    public static void main(String[] args)
    {

        Scanner scan = new Scanner(System.in);

        System.out.print("Enter the initial balance: ");
        double Balance = scan.nextDouble();

        System.out.print("Enter the amount to be added or subtracted from the account: ");
        double Amount = scan.nextDouble();
        double ServiceFee ;

        BankAccount account = new BankAccount(Balance, Amount);


        while(!(Amount == 8888 && Amount == 9999))
        {
            if (Amount >= 0)
                Balance = Balance + Amount;

                if(Amount < 0 && Amount < Balance)
                    Balance = Balance - Amount;

                else
                    System.out.println("Your overDraft fee is: " + account.getOverDraft);
                Balance = Balance - 10;

        }

        if(Amount == 8888)
            System.out.println("The current balance is: " + account.getBalance);

        if(Amount == 9999 && Balance >= 100){

            System.out.println("Your monthly service fee is: " + account.getServiceFee);
            Balance = Balance - ServiceFee;
          }
        if(Amount == 9999 && Balance < 100){
            System.out.println("Your monthly service fee is: " + account.getServiceFee);
            Balance = Balance - ServiceFee;
          }

}
}

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