2

Question about BufferedReader.

view story
linux-howto

http://www.daniweb.com – Split from - http://www.daniweb.com/forums/thread30207.html Quote: Originally Posted by visual one (Post 151556) Here's the program that I wrote, but I'm having problems with my ending balance and overdraft fee. The overdraft fee is multiplied by whatever amount I enter: can some help; here's the program: import java.io.*; import java.lang.*; public class BankAccount5 { public static void main(String[]args)throws IOException { char [] newType = new char [20]; double [] newTransaction = new double [20]; double [] newBalance = new double [20]; int o = 0; int s = 0; int t = 0; BufferedReader console = new BufferedReader ( new InputStreamReader(System.in)); System.out.println(" Enter Your Name"); String name = console.readLine(); System.out.println("Hello " + name); System.out.println(name +" " + "enter your account number"); String account = console.readLine(); System.out.println(" enter your original balance"); String Bal = console.readLine(); double initialBalance = Double.parseDouble(Bal); double balance = initialBalance; System.out.println("Enter c for Check; d for Deposit; or p to Print Summary"); char continueAnswer = console.readLine().charAt(0); boolean answer = true; newType [o] = continueAnswer; if (continueAnswer == 'p')answer = false; double Fee; double OverdraftTotal = 0; double checks = 0; double deposit = 0; double TotalBalance = 0; while (answer == true) { System.out.println("Enter amount"); String input = console.readLine(); double transaction = Double.parseDouble(input); newTransaction [o] = transaction; if (continueAnswer == 'c') checks = checks + transaction; { checks = checks + 0; if (transaction > balance) { if (transaction > 250) Fee = transaction * .10; else Fee = 25.00; balance = (balance + transaction) - Fee; newBalance [t] = TotalBalance; OverdraftTotal = OverdraftTotal + Fee; o = o + 0; t = t + 0; newType [o] = 'f'; newTransaction [o] = Fee; } else balance = balance - transaction; newBalance [t] = balance; } if (continueAnswer == 'd') deposit = deposit + transaction; balance = deposit + transaction; newBalance [t] = balance; o = o + 0; t = t + 1; System.out.println("Enter c for Check; d for Deposit; or p to Print Summary"); continueAnswer = console.readLine().charAt(0); newType [o] = continueAnswer; if (continueAnswer == 'p')answer = false; } if (balance <= 0) System.out.println("Your account insufficient, You should enter $" + balance + " to bring account current"); System.out.println("Name " + name + ", Account Number " + account); System.out.println(" Account Statement"); System.out.println("Your balance " + balance); System.out.println("Amount of checks: " + checks); System.out.println("Overdraft total fees: $" + OverdraftTotal); System.out.println("Total Checks: $" + checks); System.out.println("Total Deposits: $" + deposit); while (s < o) { System.out.println(newType[s] + " " + newTransaction [s] + " " + newBalance[s]); s = s + 1; System.out.println(""); } } } BufferedReader???whats that? (General)