Really confused on what it’s asking me to do. Here is the code it provides us wi
ID: 3870467 • Letter: R
Question
Really confused on what it’s asking me to do. Here is the code it provides us with. import java.util.Scanner; public class hw t public static void main (String [] args) Scanner sc - new Scanner(System. in)i // Test the getFeesC) method System.out.print("Enter the starting account balance: "; double bal sc.nextDoubleO; sc.nextLine); // consume the extra newline character System.out.printC"Enter the number of checks that were written: "); int checks sc.nextIntO; sc.nextlineO; // consume extra newline double fee-getFees(bal, checks); System.out.printlnc"You paid S" fee in fees. In" 1 23Explanation / Answer
BankCharges.java
import java.util.Scanner;
public class BankCharges {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the starting account balance: ");
double bal = scan.nextDouble();
System.out.println("Enter the number of checks that were written: ");
int checks = scan.nextInt();
scan.nextLine();
double fee = getFees(bal, checks);
System.out.println("Ypu paid $"+fee+" in fees. ");
}
public static double getFees(double bal, int checks) {
double charges = 10;
double rate= 0;
if(bal < 400) {
charges = charges + 15;
}
if(checks >= 1 && checks <20 ){
rate = 0.10;
} else if(checks >= 20 && checks <40 ){
rate = 0.08;
} else if(checks >= 40 && checks <60 ){
rate = 0.06;
} else {
rate = 0.04;
}
charges = charges + checks * rate;
return charges;
}
}
Output:
Enter the starting account balance:
250.75
Enter the number of checks that were written:
50
Ypu paid $28.0 in fees.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.