User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 427,493 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,471 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1046 | Replies: 3
Reply
Join Date: Sep 2006
Posts: 11
Reputation: iwlu is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
iwlu's Avatar
iwlu iwlu is offline Offline
Newbie Poster

Help Exeception in Thread

  #1  
Nov 17th, 2006
A bit of problem here, if anyone can help, I would appreciate any and all help with this. Thank you in advance.

Now I have no errors but when I execute the program I get this:

Big Bank: Monthly Checking Account Activity


----------- Account ----------- Beginning With- Ending Over- Credit Cd

Name Id Type Balance + Deposit - drawal - Fee = Balance draft Advance

Exception in thread "main" java.lang.NullPointerException

at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java :103)

at CheckingAccountsTest.main(CheckingAccountsTest.java:56)


G:\ ~1>


The Pseudo code state's this
WHILE (myFile.getEofFound() IS FALSE)
A-1-2-09) DEFINE a String Array named myFields, and ASSIGN it the value myFile.getCsvRecordFieldArray()
A-1-2-10) IF (myFields[indexForAccountType].equals(CheckingAccount.getAccountType()))
A-1-2-11) INSTANTIATE a local variable named currentAccount of class CheckingAccount, passing the following arguments:
A-1-2-12) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
A-1-2-13) Double.parseDouble(myFields[indexForBalance])
A-1-2-14) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
A-1-2-15) ASSIGN null TO currentAccount
A-1-2-16) ELSE
A-1-2-17) INSTANTIATE a local variable named currentAccount of class CheckingAccountPlus, passing the following arguments:
A-1-2-18) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
A-1-2-19) Double.parseDouble(myFields[indexForBalance])
A-1-2-20) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
A-1-2-21) ASSIGN null TO currentAccount
A-1-2-22) END IF
A-1-2-23) END WHILE

WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId]))
A-1-3-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit))
A-1-3-08) CALL method handleDeposit with the following argument list: currentAccount,
A-1-3-09) Double.parseDouble(myFields[indexForDepositAmount]
A-1-3-10) ELSE
A-1-3-11) CALL method handleWithdrawal with the following argument list: currentAccount,
A-1-3-12) Double.parseDouble(myFields[indexForWithdrawalAmount]
A-1-3-13) END IF
A-1-3-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer
A-1-3-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the
A-1-3-16) fields in the record just read available for access as elements in the myFields string array
A-1-3-17) END WHILE
WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId]))
A-1-4-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit))
A-1-4-08) CALL method handleDeposit with the following argument list: currentAccount,
A-1-4-09) Double.parseDouble(myFields[indexForDeposit]
A-1-4-10) ELSE
A-1-4-11) CALL method handleWithdrawal with the following argument list: currentAccount,
A-1-4-12) Double.parseDouble(myFields[indexForWithdrawal]
A-1-4-13) END IF
A-1-4-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer
A-1-4-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the
A-1-4-16) fields in the record just read available for access as elements in the myFields string array
A-1-4-17) END WHILE

  //public class file name
public class CheckingAccountsTest 
{
  private static final int indexForAccountId = 0;
 private static final int indexForAccountType = 2;
 private static final int indexForBalance = 5;
 private static final int indexForDepositAmount = 2;
 private static final int indexForFirstName = 3;
 private static final int indexForLastName = 4;
 private static final int indexForRecordType = 1;
 private static final int indexForWithdrawalAmount = 2;
 private static final String recordTypeForDeposit = "CKD";
 private static double sumOfBeginningBalances = 0.0;
 private static double sumOfCreditCardAdvances = 0.0;
 private static double sumOfDeposits = 0.0;
 private static double sumOfEndingBalances = 0.0;
 private static double sumOfFees = 0.0;
 private static double sumOfOverdrafts = 0.0;
 private static double sumOfWithdrawals = 0.0;

 public static void main(String args[])
 {
 MyCsvFile myFile = new MyCsvFile("monthlyBankTransactions,v05.txt");
 
 
 //display big bank title line
 System.out.println("\nBig Bank: Monthly Checking Account Activity\n");
 //display the first column heading line
 System.out.println("----------- Account ----------- Beginning\t\t    With-\t\t   Ending\tOver-\tCredit Cd");
 //display the second column heading line
 System.out.println("     Name\t   Id    Type\t Balance   +   Deposit   -  drawal   -    Fee   =  Balance\tdraft\t Advance\n");
 //Get 1st record from CSV file using method readARecord
 myFile.readARecord();
 while(myFile.getEofFound() == false)
 {
 //A-1-2-09) 
 String []myFields = myFile.getCsvRecordFieldArray();
 //A-1-2-10)
 if(myFields[indexForAccountType].equals(CheckingAccount.getAccountType())){
    CheckingAccount currentAccount = new CheckingAccount(myFields[indexForAccountId], 
    myFields[indexForFirstName], myFields[indexForLastName], Double.parseDouble(myFields[indexForBalance]));
    handleAccount(currentAccount, myFile, myFields);
    currentAccount = null;
    }
    else
    {
    CheckingAccountPlus currentAccount = new CheckingAccountPlus(myFields[indexForAccountId], 
    myFields[indexForFirstName], myFields[indexForLastName], Double.parseDouble(myFields[indexForBalance]));
    handleAccount(currentAccount, myFile, myFields);
    currentAccount = null;
    }//end if
 }//end while
//DISPLAY the report-total line using the following arguments: “Report Totals”, sumOfBeginningBalances, 
//sumOfDeposits, sumOfWithdrawals, sumOfFees, sumOfEndingBalances, sumOfOverdrafts, sumOfCreditCardAdvances, “**”
System.out.printf("Report Totals", sumOfBeginningBalances,
sumOfDeposits, sumOfWithdrawals, sumOfFees, sumOfEndingBalances, sumOfOverdrafts, sumOfCreditCardAdvances, "**");
//DISPLAY the “The information in the above report” line with the following arguments:
// myFile.getCountOfRecords()
System.out.printf("The information in the above report is from the 17 records in the following file:",
myFile.getCountOfRecords());
//DISPLAY the “Path to file” line with the following arguments: myFile.getFilePath()
System.out.printf("Path to file:", myFile.getFilePath());
//DISPLAY the “Name of file” line with the following arguments: myFile.getFileName()
System.out.printf("Name of file:", myFile.getFileName());
//DISPLAY the “End of program” line
System.out.println("\nEnd of program");
}// end main method

 //Exhibit A-1-3: Pseudo code for Overloaded Method handleAccount of Class CheckingAccountsTest
 //This private static method has no return value, and has three parameters: currentAccount of type CheckingAccount, myFile of type MyCsvFile and myFields of type String array.
 public static void handleAccount(CheckingAccount currentAccount, MyCsvFile myFile, String []myFields)
 {
 sumOfBeginningBalances += currentAccount.getBalance();
 printBeginningBalance(currentAccount);
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 while (myFile.getEofFound() == false) 
 {
   currentAccount.getAccountId().equals(myFields[indexForAccountId]);
 if(myFields[indexForRecordType].equals(recordTypeForDeposit)){
     handleDeposit(currentAccount, Double.parseDouble(myFields[indexForDepositAmount]));
      }
      else
      {
      handleWithdrawal(currentAccount,Double.parseDouble(myFields[indexForWithdrawalAmount]));
   }//end if
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 }//end while
 sumOfEndingBalances += currentAccount.getBalance();
 printEndingBalance(currentAccount);
 }//end Overloaded Method handleAccount method
 //Exhibit A-1-4: Pseudo code for Overloaded Method handleAccount of Class CheckingAccountsTest
 ///This private static method has no return value, and has three parameters: currentAccount of type CheckingAccountPlus, myFile of type MyCsvFile and myFields of type String array.
 public static void handleAccount(CheckingAccountPlus currentAccount, MyCsvFile myFile, String [] myFields)
 {
 sumOfBeginningBalances += currentAccount.getBalance();
 printBeginningBalance(currentAccount);
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
  while (myFile.getEofFound()==false)
 {
 currentAccount.getAccountId().equals (myFields[indexForAccountId]);
 if(myFields[indexForRecordType].equals(recordTypeForDeposit)){
     handleDeposit(currentAccount, Double.parseDouble(myFields[indexForDepositAmount]));
      }
      else
      {
      handleWithdrawal(currentAccount,Double.parseDouble(myFields[indexForWithdrawalAmount]));
   }//end if
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 }//end while
 sumOfEndingBalances += currentAccount.getBalance();
 printEndingBalance(currentAccount);
 }//end Overloaded Method handleAccount method
 //Exhibit A-1-5: Pseudo code for Overloaded Method handleDeposit Method of
 //Class CheckingAccountsTest
 private static void handleDeposit(CheckingAccount currentAccount, double amount)
 {
 sumOfDeposits += amount;
 currentAccount.makeDeposit(amount);
 System.out.printf("$,%.2f", amount);
 }
 
  //Exhibit A-1-6: Pseudo code for Overloaded Method handleDeposit Method of
  //Class CheckingAccountsTest
  private static void handleDeposit(CheckingAccountPlus currentAccount, double amount)
  {
  sumOfDeposits += amount;
  currentAccount.makeDeposit(amount);
  System.out.printf("$,%.2f", amount);
  }
 
  // A-1-7: Pseudo code for Overloaded Method handleWithdrawal Method of
  //Class CheckingAccountsTest
  //This private static method has no return value, and has two parameters: currentAccount of type CheckingAccount and amount of type double.
  private static void handleWithdrawal(CheckingAccount currentAccount, double amount)
  {
  if (currentAccount.makeWithdrawal(amount) == true){
   sumOfWithdrawals += amount;
   System.out.printf("$,%.2f", amount);
  }else{
   double overdraftFee = currentAccount.getOverdraftFee();
   sumOfFees += overdraftFee;
   sumOfOverdrafts += amount;
   System.out.printf("$,%.2f",overdraftFee, amount);
   
  }//end if
  
  }//end handleWithdrawal method
 //Exhibit A-1-8: Pseudo code for Overloaded Method handleWithdrawal Method of
 //Class CheckingAccountsTest
  private static void handleWithdrawal(CheckingAccountPlus currentAccount, double amount)
  {
  if (currentAccount.makeWithdrawal(amount) == true){
   sumOfWithdrawals += amount;
   System.out.printf("$,%.2f",amount);
  }else{
   double creditCardAdvance = currentAccount.getCreditCardAdvance();
   sumOfCreditCardAdvances += creditCardAdvance;
   sumOfWithdrawals += currentAccount.getActualWithdrawal();
   System.out.printf("$,%.2f",currentAccount.getActualWithdrawal(),creditCardAdvance);
   
  }//end if
  
  }//end CheckingAccountPlus handleWithdrawal method
 
 //This private static method has no return value, and has one parameter: currentAccount of type CheckingAccount. 
 private static void printBeginningBalance(CheckingAccount currentAccount)
 {
 System.out.printf("",
   currentAccount, currentAccount.getAccountId(), CheckingAccount.getAccountType(), currentAccount.getBalance()); 
 }
 
 //this private static method has no return value, and has one parameter: currentAccount of type CheckingAccountPlus.
 private static void printBeginningBalance(CheckingAccountPlus currentAccount)
 {
 System.out.printf("",
   currentAccount, currentAccount.getAccountId(), CheckingAccountPlus.getAccountType(), currentAccount.getBalance()); 
 }
 //Exhibit A-1-11: Pseudo code for Overloaded Method printEndingBalance of
 //class CheckingAccountsTest
 private static void printEndingBalance(CheckingAccount currentAccount)
 {
  System.out.printf("Account Totals", currentAccount.getAccountId(), CheckingAccount.getAccountType(),
    currentAccount.getBeginningBalance(), currentAccount.getDeposits(), currentAccount.getWithdrawals(), 
    currentAccount.getFees(), currentAccount.getBalance(), currentAccount.getOverdrafts(), " *");
 }
 
 //Exhibit A-1-12: Pseudo code for Overloaded Method printEndingBalance of
 //Class CheckingAccountsTest
 private static void printEndingBalance(CheckingAccountPlus currentAccount)
 {
  System.out.printf("Account Totals", currentAccount.getAccountId(), CheckingAccount.getAccountType(),
    currentAccount.getBeginningBalance(), currentAccount.getDeposits(), currentAccount.getWithdrawals(),
    currentAccount.getBalance(), currentAccount.getSumOfCreditCardAdvances(), " *");
 }
 
 
}//end class CheckingAccountsTestt 




AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Location: the netherlands
Posts: 15
Reputation: p.bondam is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
p.bondam's Avatar
p.bondam p.bondam is offline Offline
Newbie Poster

Re: Exeception in Thread

  #2  
Nov 17th, 2006
Originally Posted by iwlu View Post
A bit of problem here, if anyone can help, I would appreciate any and all help with this. Thank you in advance.

Now I have no errors but when I execute the program I get this:

Big Bank: Monthly Checking Account Activity


----------- Account ----------- Beginning With- Ending Over- Credit Cd

Name Id Type Balance + Deposit - drawal - Fee = Balance draft Advance

Exception in thread "main" java.lang.NullPointerException

at CheckingAccountsTest.handleAccount(CheckingAccountsTest.java :103)

at CheckingAccountsTest.main(CheckingAccountsTest.java:56)


G:\ ~1>


The Pseudo code state's this
WHILE (myFile.getEofFound() IS FALSE)
A-1-2-09) DEFINE a String Array named myFields, and ASSIGN it the value myFile.getCsvRecordFieldArray()
A-1-2-10) IF (myFields[indexForAccountType].equals(CheckingAccount.getAccountType()))
A-1-2-11) INSTANTIATE a local variable named currentAccount of class CheckingAccount, passing the following arguments:
A-1-2-12) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
A-1-2-13) Double.parseDouble(myFields[indexForBalance])
A-1-2-14) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
A-1-2-15) ASSIGN null TO currentAccount
A-1-2-16) ELSE
A-1-2-17) INSTANTIATE a local variable named currentAccount of class CheckingAccountPlus, passing the following arguments:
A-1-2-18) myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
A-1-2-19) Double.parseDouble(myFields[indexForBalance])
A-1-2-20) CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
A-1-2-21) ASSIGN null TO currentAccount
A-1-2-22) END IF
A-1-2-23) END WHILE

WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId]))
A-1-3-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit))
A-1-3-08) CALL method handleDeposit with the following argument list: currentAccount,
A-1-3-09) Double.parseDouble(myFields[indexForDepositAmount]
A-1-3-10) ELSE
A-1-3-11) CALL method handleWithdrawal with the following argument list: currentAccount,
A-1-3-12) Double.parseDouble(myFields[indexForWithdrawalAmount]
A-1-3-13) END IF
A-1-3-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer
A-1-3-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the
A-1-3-16) fields in the record just read available for access as elements in the myFields string array
A-1-3-17) END WHILE
WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId().equals(myFields[indexForAccountId]))
A-1-4-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit))
A-1-4-08) CALL method handleDeposit with the following argument list: currentAccount,
A-1-4-09) Double.parseDouble(myFields[indexForDeposit]
A-1-4-10) ELSE
A-1-4-11) CALL method handleWithdrawal with the following argument list: currentAccount,
A-1-4-12) Double.parseDouble(myFields[indexForWithdrawal]
A-1-4-13) END IF
A-1-4-14) CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer
A-1-4-15) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the value from the
A-1-4-16) fields in the record just read available for access as elements in the myFields string array
A-1-4-17) END WHILE

  //public class file name
public class CheckingAccountsTest 
{
  private static final int indexForAccountId = 0;
 private static final int indexForAccountType = 2;
 private static final int indexForBalance = 5;
 private static final int indexForDepositAmount = 2;
 private static final int indexForFirstName = 3;
 private static final int indexForLastName = 4;
 private static final int indexForRecordType = 1;
 private static final int indexForWithdrawalAmount = 2;
 private static final String recordTypeForDeposit = "CKD";
 private static double sumOfBeginningBalances = 0.0;
 private static double sumOfCreditCardAdvances = 0.0;
 private static double sumOfDeposits = 0.0;
 private static double sumOfEndingBalances = 0.0;
 private static double sumOfFees = 0.0;
 private static double sumOfOverdrafts = 0.0;
 private static double sumOfWithdrawals = 0.0;

 public static void main(String args[])
 {
 MyCsvFile myFile = new MyCsvFile("monthlyBankTransactions,v05.txt");
 
 
 //display big bank title line
 System.out.println("\nBig Bank: Monthly Checking Account Activity\n");
 //display the first column heading line
 System.out.println("----------- Account ----------- Beginning\t\t    With-\t\t   Ending\tOver-\tCredit Cd");
 //display the second column heading line
 System.out.println("     Name\t   Id    Type\t Balance   +   Deposit   -  drawal   -    Fee   =  Balance\tdraft\t Advance\n");
 //Get 1st record from CSV file using method readARecord
 myFile.readARecord();
 while(myFile.getEofFound() == false)
 {
 //A-1-2-09) 
 String []myFields = myFile.getCsvRecordFieldArray();
 //A-1-2-10)
 if(myFields[indexForAccountType].equals(CheckingAccount.getAccountType())){
    CheckingAccount currentAccount = new CheckingAccount(myFields[indexForAccountId], 
    myFields[indexForFirstName], myFields[indexForLastName], Double.parseDouble(myFields[indexForBalance]));
    handleAccount(currentAccount, myFile, myFields);
    currentAccount = null;
    }
    else
    {
    CheckingAccountPlus currentAccount = new CheckingAccountPlus(myFields[indexForAccountId], 
    myFields[indexForFirstName], myFields[indexForLastName], Double.parseDouble(myFields[indexForBalance]));
    handleAccount(currentAccount, myFile, myFields);
    currentAccount = null;
    }//end if
 }//end while
//DISPLAY the report-total line using the following arguments: “Report Totals”, sumOfBeginningBalances, 
//sumOfDeposits, sumOfWithdrawals, sumOfFees, sumOfEndingBalances, sumOfOverdrafts, sumOfCreditCardAdvances, “**”
System.out.printf("Report Totals", sumOfBeginningBalances,
sumOfDeposits, sumOfWithdrawals, sumOfFees, sumOfEndingBalances, sumOfOverdrafts, sumOfCreditCardAdvances, "**");
//DISPLAY the “The information in the above report” line with the following arguments:
// myFile.getCountOfRecords()
System.out.printf("The information in the above report is from the 17 records in the following file:",
myFile.getCountOfRecords());
//DISPLAY the “Path to file” line with the following arguments: myFile.getFilePath()
System.out.printf("Path to file:", myFile.getFilePath());
//DISPLAY the “Name of file” line with the following arguments: myFile.getFileName()
System.out.printf("Name of file:", myFile.getFileName());
//DISPLAY the “End of program” line
System.out.println("\nEnd of program");
}// end main method

 //Exhibit A-1-3: Pseudo code for Overloaded Method handleAccount of Class CheckingAccountsTest
 //This private static method has no return value, and has three parameters: currentAccount of type CheckingAccount, myFile of type MyCsvFile and myFields of type String array.
 public static void handleAccount(CheckingAccount currentAccount, MyCsvFile myFile, String []myFields)
 {
 sumOfBeginningBalances += currentAccount.getBalance();
 printBeginningBalance(currentAccount);
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 while (myFile.getEofFound() == false) 
 {
   currentAccount.getAccountId().equals(myFields[indexForAccountId]);
 if(myFields[indexForRecordType].equals(recordTypeForDeposit)){
     handleDeposit(currentAccount, Double.parseDouble(myFields[indexForDepositAmount]));
      }
      else
      {
      handleWithdrawal(currentAccount,Double.parseDouble(myFields[indexForWithdrawalAmount]));
   }//end if
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 }//end while
 sumOfEndingBalances += currentAccount.getBalance();
 printEndingBalance(currentAccount);
 }//end Overloaded Method handleAccount method
 //Exhibit A-1-4: Pseudo code for Overloaded Method handleAccount of Class CheckingAccountsTest
 ///This private static method has no return value, and has three parameters: currentAccount of type CheckingAccountPlus, myFile of type MyCsvFile and myFields of type String array.
 public static void handleAccount(CheckingAccountPlus currentAccount, MyCsvFile myFile, String [] myFields)
 {
 sumOfBeginningBalances += currentAccount.getBalance();
 printBeginningBalance(currentAccount);
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
  while (myFile.getEofFound()==false)
 {
 currentAccount.getAccountId().equals (myFields[indexForAccountId]);
 if(myFields[indexForRecordType].equals(recordTypeForDeposit)){
     handleDeposit(currentAccount, Double.parseDouble(myFields[indexForDepositAmount]));
      }
      else
      {
      handleWithdrawal(currentAccount,Double.parseDouble(myFields[indexForWithdrawalAmount]));
   }//end if
 myFile.readARecord();
 myFields = myFile.getCsvRecordFieldArray();
 
 }//end while
 sumOfEndingBalances += currentAccount.getBalance();
 printEndingBalance(currentAccount);
 }//end Overloaded Method handleAccount method
 //Exhibit A-1-5: Pseudo code for Overloaded Method handleDeposit Method of
 //Class CheckingAccountsTest
 private static void handleDeposit(CheckingAccount currentAccount, double amount)
 {
 sumOfDeposits += amount;
 currentAccount.makeDeposit(amount);
 System.out.printf("$,%.2f", amount);
 }
 
  //Exhibit A-1-6: Pseudo code for Overloaded Method handleDeposit Method of
  //Class CheckingAccountsTest
  private static void handleDeposit(CheckingAccountPlus currentAccount, double amount)
  {
  sumOfDeposits += amount;
  currentAccount.makeDeposit(amount);
  System.out.printf("$,%.2f", amount);
  }
 
  // A-1-7: Pseudo code for Overloaded Method handleWithdrawal Method of
  //Class CheckingAccountsTest
  //This private static method has no return value, and has two parameters: currentAccount of type CheckingAccount and amount of type double.
  private static void handleWithdrawal(CheckingAccount currentAccount, double amount)
  {
  if (currentAccount.makeWithdrawal(amount) == true){
   sumOfWithdrawals += amount;
   System.out.printf("$,%.2f", amount);
  }else{
   double overdraftFee = currentAccount.getOverdraftFee();
   sumOfFees += overdraftFee;
   sumOfOverdrafts += amount;
   System.out.printf("$,%.2f",overdraftFee, amount);
   
  }//end if
  
  }//end handleWithdrawal method
 //Exhibit A-1-8: Pseudo code for Overloaded Method handleWithdrawal Method of
 //Class CheckingAccountsTest
  private static void handleWithdrawal(CheckingAccountPlus currentAccount, double amount)
  {
  if (currentAccount.makeWithdrawal(amount) == true){
   sumOfWithdrawals += amount;
   System.out.printf("$,%.2f",amount);
  }else{
   double creditCardAdvance = currentAccount.getCreditCardAdvance();
   sumOfCreditCardAdvances += creditCardAdvance;
   sumOfWithdrawals += currentAccount.getActualWithdrawal();
   System.out.printf("$,%.2f",currentAccount.getActualWithdrawal(),creditCardAdvance);
   
  }//end if
  
  }//end CheckingAccountPlus handleWithdrawal method
 
 //This private static method has no return value, and has one parameter: currentAccount of type CheckingAccount. 
 private static void printBeginningBalance(CheckingAccount currentAccount)
 {
 System.out.printf("",
   currentAccount, currentAccount.getAccountId(), CheckingAccount.getAccountType(), currentAccount.getBalance()); 
 }
 
 //this private static method has no return value, and has one parameter: currentAccount of type CheckingAccountPlus.
 private static void printBeginningBalance(CheckingAccountPlus currentAccount)
 {
 System.out.printf("",
   currentAccount, currentAccount.getAccountId(), CheckingAccountPlus.getAccountType(), currentAccount.getBalance()); 
 }
 //Exhibit A-1-11: Pseudo code for Overloaded Method printEndingBalance of
 //class CheckingAccountsTest
 private static void printEndingBalance(CheckingAccount currentAccount)
 {
  System.out.printf("Account Totals", currentAccount.getAccountId(), CheckingAccount.getAccountType(),
    currentAccount.getBeginningBalance(), currentAccount.getDeposits(), currentAccount.getWithdrawals(), 
    currentAccount.getFees(), currentAccount.getBalance(), currentAccount.getOverdrafts(), " *");
 }
 
 //Exhibit A-1-12: Pseudo code for Overloaded Method printEndingBalance of
 //Class CheckingAccountsTest
 private static void printEndingBalance(CheckingAccountPlus currentAccount)
 {
  System.out.printf("Account Totals", currentAccount.getAccountId(), CheckingAccount.getAccountType(),
    currentAccount.getBeginningBalance(), currentAccount.getDeposits(), currentAccount.getWithdrawals(),
    currentAccount.getBalance(), currentAccount.getSumOfCreditCardAdvances(), " *");
 }
 
 
}//end class CheckingAccountsTestt 
hi,
I think the problem is the use of "CheckingAccount.getAccountType" etc. in different calls to System.out.printf .
all other parameters are "currentAccount.get..."
Try to change the first in the latter and try again.
bye,
peter
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Exeception in Thread

  #3  
Nov 18th, 2006
Start at the line number given in the exception and work back from there.
You're trying to call a method on an unitialised object reference, something that's impossible.
Once you know what reference that is, work back to find out why it's not initialised (or maybe you're working with the wrong one?).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Nov 2006
Location: the netherlands
Posts: 15
Reputation: p.bondam is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
p.bondam's Avatar
p.bondam p.bondam is offline Offline
Newbie Poster

Re: Exeception in Thread

  #4  
Nov 19th, 2006
there is another mysterious statement, namely:

after the while, in both handleAccounts, after the first '{'

xxx.equals(yyy);

in my humble opinion that isn't a statement! (otherwise : what does it mean?)
I wonder how you got through the compiler...

I tried to copy the lot, as to try it myself, but there is too much code missing (classes and so on)

by the way....
1. is there a manner to get java text from the code into your (my) own (java) environment??...copy & paste gives one endless line without carriage-returns)
2. if you feel like it, sent me all you have, as an attachment, I like a challenge.
3. I hate this kind of 'generated' code, it is almost unreadable (while the opposite is intended, I suppose).
4. I use the jGRASP-shell for JAVA, and can strongly recommend it
(www.jgrasp.com)
5. ?

good luck,
peter



Originally Posted by p.bondam View Post
hi,
I think the problem is the use of "CheckingAccount.getAccountType" etc. in different calls to System.out.printf .
all other parameters are "currentAccount.get..."
Try to change the first in the latter and try again.
bye,
peter
maybe later
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 7:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC