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
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 ); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started