Exercise 3: A bank charges $10 per month plus the following check fees for a com
ID: 3760031 • Letter: E
Question
Exercise 3: A bank charges $10 per month plus the following check fees for a commercial checking account: $ .10 each for less than 20 checks $ .08 each for 20-39 checks $ .06 each for 40-59 checks $ .04 each for 60 or more checks The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied). Design a class that stores the beginning balance of an account and the number of checks written. It should also have a method that returns the bank's service fee for the month. Renumber to review: toString methods static method and variables (instance data) Boolean method and variables (instance data)Explanation / Answer
import java.util.*;
class bank
{
public static void main(String args[])
{
double serch, ch=0,curbal, checks,net;
Scanner o = new Scanner(System.in);
System.out.println("Enter Current
balance of Account");
curbal=(Double.parseDouble
(o.nextLine()));
if(curbal<400)
{
ch=15;
}
System.out.println("Enter Checks
written");
checks=(Double.parseDouble
(o.nextLine()));
serch=cal(checks);
net=serch+ch+10;
System.out.println("Bank Services
charges="+net);
System.out.println("Bank Balance ="+
(curbal-net));
}
public static double cal(double c)
{
double cfees=0;
if(c>0 && c<20)
{
cfees=c*.1;
}
if(c>=20 && c<=39)
{
cfees=c*.08;
}
if(c>=40 && c<=59)
{
cfees=c*.06;
}
if(c>=60)
{
cfees=c*.04;
}
return cfees;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.