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

The file BankCharge.java is a working Java application that will allow the user

ID: 3879124 • Letter: T

Question

The file BankCharge.java is a working Java application that will allow the user to enter a number of checks written for a bank. The program is lacking the calculations to find the total bank fees for the checking account. Change the source code to correctly calculate the bank charges using the following algorithm:

A base fee of $10 is charged regardless of the number of checks. Then, the following is added:

10 cents each for less than 30 checks

8 cents each for 30-49 checks

6 cents each for 50-74 checks

4 cents each for 75 or more checks

// This application receives a number of checks written by
// a bank customer and calculates the monthly service charge.

import javax.swing.JOptionPane;
import java.text.DecimalFormat;

public class BankCharge
{
   public static void main( String args[] )
   {
      int    numChecks;   // Input value - checks written
      double bankCharge; // Output value - bank charges

      // Set up for monetary decimal formatting
      DecimalFormat twoDigits = new DecimalFormat( "0.00" );
     
      // Read number of checks from user, convert to integer
      numChecks = Integer.parseInt(
              JOptionPane.showInputDialog( "Enter number of checks" ));

      // Calculate the total bank charge
      // ==> REPLACE the statement below with the "if" logic required by the specs
      bankCharge = 0;






     
     // Display results
      JOptionPane.showMessageDialog ( null, "Monthly bank charge: $"
                                      + twoDigits.format(bankCharge));

      System.exit( 0 );
   }
}

Explanation / Answer

/*To solve this Problem, you just need to add if-else conditions in the program

* and some calculations

* Steps for solutions (1) Initialize bankCharge with $10 as base fee

* (2) Check condition and do calculation like

* charges=(number of check * number of cents)

* bankCharge =bankCharge + charges/100

*

* I am assuming that number of input checks will always be greater then or equal to 0*/

// This application receives a number of checks written by

// a bank customer and calculates the monthly service charge.

import javax.swing.JOptionPane;

import java.text.DecimalFormat;

public class BankCharge

{

public static void main( String args[] )

{

int numChecks; // Input value - checks written

double bankCharge; // Output value - bank charges

// Set up for monetary decimal formatting

DecimalFormat twoDigits = new DecimalFormat( "0.00" );

// Read number of checks from user, convert to integer

numChecks = Integer.parseInt(

JOptionPane.showInputDialog( "Enter number of checks" ));

// Calculate the total bank charge

// ==> REPLACE the statement below with the "if" logic required by the specs

//Initialize bankCharge with $10 as base fee

bankCharge = 10;

//Now If-Else conditions for rest

//charges/100 to convert cents to dollars

if(numChecks<30)

{

double charges=numChecks *10;

bankCharge =bankCharge+(charges/100);

}

else if(numChecks>=30 && numChecks<=49)

{

double charges=numChecks *8;

bankCharge =bankCharge+(charges/100);

}

else if(numChecks>=50 && numChecks<=74)

{

double charges=numChecks *6;

bankCharge =bankCharge+(charges/100);

}

else if(numChecks>=75)

{

double charges=numChecks *4;

bankCharge =bankCharge+(charges/100);

}

// Display results

JOptionPane.showMessageDialog ( null, "Monthly bank charge: $"

+ twoDigits.format(bankCharge));

System.exit( 0 );

}

}

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