Hi,
I have been trying to get my program to run for a few days now. I have gotten it almost completed I think, but keep getting "error: variable checkFee might not have been initialized" on line 37.
import java.util.Scanner; // scanner class
public class PROB3_CHAL15
{
public static void main(String[] args)
{
double checks =0,
totalfee =0,
fee = 10,
fee1 =.1,
fee2 = .08,
fee3 = .06,
fee4 = .04,
checkFee;
String input;
Scanner keyboard = new Scanner(System.in);
int number;
System.out.println("Please enter the number of checks you wrote for the past month");
input = keyboard.nextLine();
if (checks < 0) // negative is false
{
System.out.print("ERROR: You cannot enter a negative amount!");
}
if(checks >= 60)
checkFee =(fee4);
else if(checks >= 40)
checkFee = (fee3);
else if(checks >=20)
checkFee = (fee2);
else if(checks <20)
checkFee = (fee1);
//adds all fees
totalfee = (fee + checkFee * checks);
//if closing true(because user didn't enter negative number, show total fees
System.out.print("Your total monthly Bank Fees are $" + totalfee);
}
}
This is what I have so far. Also, the original question is as follows:
A bank charges a base fee of $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
Write a program that asks for the number of checks written for the month. The programs should then calculate and display the bank's service fees for the month.