Hello guys. I needed some help with my calculations. I'm having a problem with having my output display the total amount. I believe the problem is coming from trying the float calculation.

Recommended Answers

All 3 Replies

I figured it out. I misspelled deposited twice in the program lol. But if you guys can help me out with making the code simplier, please let me know.

um... where is your code?

Sorry I mistakely removed it. This is it again but fixed up. Just need to know how I can make it more simple.

public class checkbook
{//begin class
	public static void main(String[] args) throws IOException
	{//begin main

		String currentBalance, checksWritten, cashWithdrawn, cashDeposited, feeCharged;
		float cBalance, cWritten, cWithdrawn, cDeposited, fCharged, addedBalance, subtractedBalance, newbalance;
		BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));

		Date presentDate = new Date(); //places current time and date
		System.out.println("\tMY CHECKBOOK BALANCE PROGRAM   " + presentDate);
		System.out.println();
		System.out.print("\tEnter your balance please: $ ");
			currentBalance = dataIn.readLine();
			cBalance = Float.parseFloat(currentBalance);
		System.out.print("\tEnter the total dollar amount of the checks you've written: $ ");
			checksWritten = dataIn.readLine();
			cWritten = Float.parseFloat(checksWritten);
		System.out.print("\tEnter the total dollar amount of what you have withdrawn: $ ");
			cashWithdrawn = dataIn.readLine();
			cWithdrawn = Float.parseFloat(cashWithdrawn);
		System.out.print("\tEnter the total dollar amount of what you have deposited: $ ");
			cashDeposited = dataIn.readLine();
			cDeposited = Float.parseFloat(cashDeposited);
		System.out.print("\tEnter the total fee that the bank has charged you: $ ");
			feeCharged = dataIn.readLine();
			fCharged = Float.parseFloat(feeCharged);

			//calculations
			addedBalance = cBalance + cDeposited;
			subtractedBalance = fCharged + cWritten + cWithdrawn;
			newbalance = addedBalance - subtractedBalance;

			//output
			System.out.print("YOUR NEW BALANCE IS " + newbalance);

	}//end main
}//end class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.