Please help urgently needed. Best program answer gets 1,000 points. Thank you. A
ID: 670690 • Letter: P
Question
Please help urgently needed. Best program answer gets 1,000 points. Thank you.
After the initial balance given show:
· the current balance,
· the new balance,
· the interest earned (or Fees accrued) for the month and
· the cumulative interest (or Fees)(Year to Date)
After processing a month just ask the user if they want to see the results for another month (i.e. don’t ask the user for a set number of months to process). Let your program indefinitely ask if another month is to be processed until the user says “no.”
import java.util.*;
public class Banking
{
public static void main(String[] args)
{
final double FEE_CHECK = 25.00;
final double FEE_SAVINGS = 10.00;
final double SAV_INT = 0.04; //Savings interest rate 4%
final double CHK_INT1 = 0.03; //Checking interest rate 3% 1st Tier
final double CHK_INT2 = 0.05; //Checking interest rate 5% 2nd Tier
long acctNum; //Account number is a long integer
char acctType;
double minBal, currBal; //Minimum Balance and Current Balance
double newBal, interest; //NewBalance and Interest
Scanner scan = new Scanner(System.in); //Keyboard input
System.out.print("Enter account number: ");
acctNum = scan.nextLong();
scan.nextLine(); //Just to clear the input buffer of carriage return
//Get account Type...Checking or Saving with validation
do
{
System.out.print("Enter account type - (C)hecking or (S)avings: ");
acctType = scan.nextLine().toLowerCase().charAt(0);
if ( acctType != 's' && acctType != 'c' )
System.out.println("Invalid Response! ");
} while ( acctType != 's' && acctType != 'c' );
//Get minimum balance for account type
System.out.print("Enter minimum balance for account type: ");
minBal = scan.nextDouble();
//Get account balance
System.out.print("Enter account balance: ");
currBal = scan.nextDouble();
//Check if any fees apply
if (currBal < minBal)
{
if (acctType == 's')
newBal = currBal - FEE_SAVINGS; //Savings low balance fee
else
newBal = currBal - FEE_CHECK; //Checking low balance fee
}
else //Apply interest rates
{
if (acctType == 's')
newBal = (currBal * SAV_INT) + currBal;
else //Handle Checking interest 2 tiers
if (currBal >= minBal && currBal <= (minBal + 5000)) //Check range of balance
newBal = (currBal * CHK_INT1) + currBal;
else
newBal = (currBal * CHK_INT2) + currBal;
} //end else
//Print Results
System.out.println("Account Number: " + acctNum);
System.out.println("Account Type: " + acctType);
System.out.println("Current Balance: " + currBal);
System.out.println("New Balance: " + newBal);
} //main
}
Explanation / Answer
package mani;
import java.util.*;
public class Banking
{
public static void main(String[] args)
{
final double FEE_CHECK = 25.00;
final double FEE_SAVINGS = 10.00;
final double SAV_INT = 0.04; //Savings interest rate 4%
final double CHK_INT1 = 0.03; //Checking interest rate 3% 1st Tier
final double CHK_INT2 = 0.05; //Checking interest rate 5% 2nd Tier
long acctNum; //Account number is a long integer
char acctType;
double minBal, currBal; //Minimum Balance and Current Balance
double newBal, interest; //NewBalance and Interest
Scanner scan = new Scanner(System.in); //Keyboard input
System.out.print("Enter account number: ");
acctNum = scan.nextLong();
scan.nextLine(); //Just to clear the input buffer of carriage return
//Get account Type...Checking or Saving with validation
do
{
System.out.print("Enter account type - (C)hecking or (S)avings: ");
acctType = scan.nextLine().toLowerCase().charAt(0);
if ( acctType != 's' && acctType != 'c' )
System.out.println("Invalid Response! ");
} while ( acctType != 's' && acctType != 'c' );
//Get minimum balance for account type
System.out.print("Enter minimum balance for account type: ");
minBal = scan.nextDouble();
//Get account balance
System.out.print("Enter account balance: ");
currBal = scan.nextDouble();
//Check if any fees apply
if (currBal < minBal)
{
if (acctType == 's')
newBal = currBal - FEE_SAVINGS; //Savings low balance fee
else
newBal = currBal - FEE_CHECK; //Checking low balance fee
}
else //Apply interest rates
{
if (acctType == 's')
newBal = (currBal * SAV_INT) + currBal;
else //Handle Checking interest 2 tiers
if (currBal >= minBal && currBal <= (minBal + 5000)) //Check range of balance
newBal = (currBal * CHK_INT1) + currBal;
else
newBal = (currBal * CHK_INT2) + currBal;
} //end else
//Print Results
System.out.println("Account Number: " + acctNum);
System.out.println("Account Type: " + acctType);
System.out.println("Current Balance: " + currBal);
System.out.println("New Balance: " + newBal);
int f=1;
do{
if (currBal >= minBal && currBal <= (minBal + 5000)){ //Check range of balance
interest=(newBal*CHK_INT1);
newBal = interest + newBal;
}
else{
interest=(newBal*CHK_INT2);
newBal = interest + newBal;
}
System.out.println("Account Number: " + acctNum);
System.out.println("Account Type: " + acctType);
System.out.println("Inerest for one month: "+interest);
System.out.println("New Balance: " + newBal);
System.out.println("Do you want see for next month 1.for yes 2.for No: ");
f=scan.nextInt();
}while(f!=2);
} //main
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.