File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Program Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program Help" Watch "Program Help" New topic
Author

Program Help

mike hew
Greenhorn

Joined: Oct 26, 2006
Posts: 27
Here is what I have so far, but I only need help understanding what is highlighted.

I'm not getting what is ask done or I'm totaly not understanding the question.

My errors so far are:

-Called Compiler C:\PROGRA~1\Java\JDK15~1.0_0\bin\javac.exe-
-Target File: G:\9\CheckingAccountTest.java-
G:\9\CheckingAccountTest.java:104: 'else' without 'if'
else
^
G:\9\CheckingAccountTest.java:139: illegal start of expression
private void handleAccount(currentAccount.getCheckingAccount, myFile.getMyCsvFile(), String myFields[])
^
G:\9\CheckingAccountTest.java:425: ';' expected
}//
^
G:\9\CheckingAccountTest.java:427: '}' expected
}
^
4 errors

-Finished-

//Requirement

//Design, code and thoroughly test the following programming problem:

//Big Bank offers customers two types of checking accounts: "regular" and "plus." The main difference between the two types of checking accounts is what happens when a customer writes a bad check (insufficient funds in the account to pay the check).

//When a customer with a "regular" checking account writes a bad check, the check is returned to the payee and the customer's checking account is charged an overdraft fee of $50.00. On the other hand, when a customer with a "plus" checking account writes a bad check, the payee is paid and the customer's credit card account is charged with an amount sufficient to bring the customer's checking account balance back to zero.

//This project uses the MyCsvFile class to accept its input from a CSV (comma separated value) file. The CSV file and class file are provided by the instructor and are described in this document's Exhibit B-1 and D. All of the functionality needed to handle the CSV file is provided the MyCsvFile.class file. You must place the Data folder (and its CSV file, monthlyBankTransactions,v05.txt) and the MyCsvFile.class file into your solution folder. You do not have any programming deliverable for the MyCsvFile class; the instructor has written the Java code for that class and has provided the bytecode class file for you to use.

//You will develop three new classes for this project: CheckingAccount, CheckingAccountPlus and CheckingAccountsTest. For each of these classes:
//1. Follow the UML class diagram and the pseudo code shown in the document's "Exhibit A-1-1" through "Exhibit A-3-8";
//2. Use descriptive identifier names that reveal the exact purpose of the variable in your program. Do not use abbreviations;

//The CheckingAccount class handles all of the requirements for a "regular" checking account, and most of the requirements for a "plus" account. As a result, the CheckingAccount class is a superclass from which the CheckingAccountPlus class is derived. In other words, the CheckingAccountPlus class extends (inherits from), and is a subclass of, the CheckingAccount class. The CheckingAccount class has two methods that are overridden by the CheckingAccountPlus class: getAccountType and makeWithdrawal.

//The CheckingAccountsTest class enables you to test your CheckingAccount and CheckingAccountPlus classes, tapping into the CSV file (see Exhibit D) via the functionality in the MyCsvFile class (see Exhibit B-1), and producing a report of customer checking account activity using appropriate format specifiers and horizontal and vertical spacing as shown in this document's Exhibit C. Specifically, for each customer in the CSV file, this class:
//1. Determines the customer's account type (regular or plus) and instantiates an appropriate object named currentAccount (from class CheckingAccount or class CheckingAccountPlus). The details for dealing with a specific customer (regular or plus) are handled through pairs of overloaded methods whose signature differs by only one parameter, whose type is either CheckingAccount or CheckingAccountPlus, depending upon the account type (regular or plus) found in the CSV file for the customer;
//2. Calls method handleAccount, which:
//2.1. Calls method currentAccount.getBalance and adds its return value to sumOfBeginningBalances;
//2.2. Calls method printBeginningBalance;
//2.3. Calls method myFile.readARecord to get the customer's first deposit or withdrawal record;
//2.4. Calls method myFile.getCsvRecordFieldArray to get the values for the first deposit or withdrawal record;
//2.5. Repeats the following while the CSV file is not at end and there are still deposits and withdrawals to process for this customer:
//2.5.1. If the current record is a deposit calls method handleDeposit; otherwise, calls method handleWithdrawal;
//2.5.2. Calls method myFile.readARecord to get the customer's next deposit or withdrawal record, if any;
//2.5.3. Calls method myFile.getCsvRecordFieldArray to get the values for the next deposit or withdrawal record, if any;
//2.6. Calls method currentAccount.getBalance and adds its return value to sumOfEndingBalances;
//2.7. Calls method printEndingBalance;



//Exhibit A-1-1: UML Class Diagram of Class CheckingAccountsTest
//CheckingAccountsTest
//-indexForAccountId : int = 0 // this field is static final
//-indexForAccountType : int = 2 // this field is static final
//-indexForBalance : int = 5 // this field is static final
//-indexForDepositAmount : int = 2 // this field is static final
//-indexForFirstName : int = 3 // this field is static final
//-indexForLastName : int = 4 // this field is static final
//-indexForRecordType : int = 1 // this field is static final
//-indexForWithdrawalAmount : int = 2 // this field is static final
//-recordTypeForDeposit : String = "CKD" // this field is static final
//-sumOfBeginningBalances : double = 0.0 // this field is static
//-sumOfCreditCardAdvances : double = 0.0 // this field is static
//-sumOfDeposits : double = 0.0 // this field is static
//-sumOfEndingBalances : double = 0.0 // this field is static
//-sumOfFees : double = 0.0 // this field is static
//-sumOfOverdrafts : double = 0.0 // this field is static
//-sumOfWithdrawals : double = 0.0 // this field is static
//+main(args[ ] : String)
//-handleAccount(currentAccount : CheckingAccount, myFile : MyCsvFile, myFields[ ] : String)
//-handleAccount(currentAccount : CheckingAccountPlus, myFile : MyCsvFile, myFields[ ] : String)
//-handleDeposit(currentAccount : CheckingAccount, amount : double)
//-handleDeposit(currentAccount : CheckingAccountPlus, amount : double)
//-handleWithdrawal(currentAccount : CheckingAccount, amount : double)
//-handleWithdrawal(currentAccount : CheckingAccountPlus, amount : double)
//-printBeginningBalance(currentAccount : CheckingAccount)
//-printBeginningBalance(currentAccount : CheckingAccountPlus)
//-printEndingBalance(currentAccount : CheckingAccount)
//-printEndingBalance(currentAccount : CheckingAccountPlus)
//public class file name
public class CheckingAccountsTest
{
// start of main method
public static void main(String args[])
{
//local variable named myFile of class MyCsvFile
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\n");

//display the second column heading line
System.out.println(" Name\t Id Type\t Balance + Deposit - drawal - Fee = Balance\tdraft\t Advance");

//Get 1st record from CSV file using method readARecord
myFile.readARecord();

while(myFile.getEofFound() == false)
{

//DEFINE a String Array named myFields, and ASSIGN it the value myFile.getCsvRecordFieldArray()
String myFields[] = myFile.getCsvRecordFieldArray();

//IF (myFields[indexForAccountType].equals(CheckingAccount.getAccountType()))
// INSTANTIATE a local variable named currentAccount of class CheckingAccount, passing the following arguments:
// myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
// Double.parseDouble(myFields[indexForBalance])
// CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
// ASSIGN null TO currentAccount
if(myFields[indexForAccountType].equals(CheckingAccount.getAccountType()));
CheckingAccount currentAccount = new CheckingAccount(myFields[indexForAccountId], myFields[indexForFirstName],
myFields[indexForLastName], Double.parseDouble(myFields[indexForBalance]));
Object.handleAccount (currentAccount, myFile, myFields);
currentAccount = null;

else
//INSTANTIATE a local variable named currentAccount of class CheckingAccountPlus, passing the following arguments:
// myFields[indexForAccountId], myFields[indexForFirstName], myFields[indexForLastName],
// Double.parseDouble(myFields[indexForBalance])
// CALL method handleAccount of this class, passing the following arguments: currentAccount, myFile, myFields
// ASSIGN null TO currentAccount
CheckingAccountPlus currentAccount = new CheckingAccountPlus(myFields[indexForAccountId],
myFields[indexForFirstName], myFields[indexForLastName],Double.parseDouble(myFields[indexForBalance]));
Object.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 and "**"
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:\n\t",
myFile.getCountOfRecords());

//DISPLAY the "Path to file" line with the following arguments: myFile.getFilePath()
System.out.printf("Path to file: %s\n",myFile.getFilePath());

//DISPLAY the "Name of file" line with the following arguments: myFile.getFileName()
System.out.printf("Name of file: %s\n",myFile.getFilePath());

//DISPLAY the "End of program" line
System.out.println("\nEnd of program");

//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.
private void handleAccount(currentAccount.getCheckingAccount, myFile.getMyCsvFile(), String myFields[])
{
//A-1-3-01) CALL method currentAcccount.getBalance and ADD its return value to sumOfBeginningBalances
sumOfBeginningBalances = Object.currentAcccount.getBalance();
//A-1-3-02) CALL method printBeginningBalance with the following argument list: currentAccount
Object.printBeginningBalance(currentAccount);
//A-1-3-03) CALL method myFile.readARecord, which reads the 1st record after the Balance record (a deposit or withdrawal) for the current customer
Object.myFile.readARecord();
//A-1-3-04) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array.
//This makes the values from the fields in the record just read available for access as elements in the myFields
//string array
String myFields[] = Object.myFile.getCsvRecordFileArray();
//A-1-3-06) WHILE (myFile.getEofFound() IS FALSE AND currentAccount.getAccountId()
//.equals(myFields[indexForAccountId]))
while (myFile.getEofFound()==false)
{
currentAccount.getAccountId().equals (myFields[indexForAccountId]);
//A-1-3-07) IF (myFields[indexForRecordType].equals(recordTypeForDeposit))
if(myFields[indexForRecordType].equals(recordTypeForDeposit))
//A-1-3-08) CALL method handleDeposit with the following argument list: currentAccount,
Object.handleDeposit(currentAccount, Double.parseDouble(myFields[indexForDepositAmount]));

else
//A-1-3-11) CALL method handleWithdrawal with the following argument list: currentAccount,
Object.hadleWithdrawal(currentaccount, Double.parseDouble(myFields[indexForWithdrawalAmount]));

//END IF

//CALL method myFile.readARecord, which reads the next deposit or withdrawal record, if any, for this customer
Object.myFile.readARecord();
//CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array.
String myFields[] = Object.myFile.getCsvRecordFieldArray();

}//END WHILE

//A-1-3-18) CALL method currentAcccount.getBalance and ADD its return value to sumOfEndingBalances
sumOfEndingBalances = Object.currentAcccount.getBalance();
//A-1-3-19) CALL method printEndingBalance with the following argument list: currentAccount
Object.printEndingBalance(currentaccount);
//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.

//A-1-4-01) CALL method currentAcccount.getBalance and ADD its return value to sumOfBeginningBalances
sumOfBeginningBalances = Object.currentAcccount.getBalance();
//A-1-4-02) CALL method printBeginningBalance with the following argument list: currentAccount
//A-1-4-03) CALL method myFile.readARecord, which reads the 1st record after the Balance record (a deposit or withdrawal) for the current customer
//A-1-4-04) CALL method myFile.getCsvRecordFieldArray and ASSIGN its return value to myFields, a String array. This makes the values from the
//A-1-4-05) fields in the record just read available for access as elements in the myFields string array
//A-1-4-06) 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(myFiel ds[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(myFiel ds[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
//A-1-4-18) CALL method currentAcccount.getBalance and ADD its return value to sumOfEndingBalances
//A-1-4-19) CALL method printEndingBalance with the following argument list: currentAccount

//Exhibit A-1-5: Pseudo code for Overloaded Method handleDeposit 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.
//A-1-5-01) ADD amount TO sumOfDeposits
sumOfDeposits = amount;
//A-1-5-02) CALL method currentAccount.makeDeposit, passing it the following arguments: amount
//A-1-5-03) DISPLAY the deposit line using the following arguments: amount

//Exhibit A-1-6: Pseudo code for Overloaded Method handleDeposit Method of
//Class CheckingAccountsTest
//This private static method has no return value, and has two parameters: currentAccount of type CheckingAccountPlus and amount of type double.
//A-1-6-01) ADD amount TO sumOfDeposits
sumOfDeposits = amount;
//A-1-6-02) CALL method currentAccount.makeDeposit, passing it the following arguments: amount
//A-1-6-03) DISPLAY the deposit line using the following arguments: amount


//Exhibit 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.
//A-1-7-01) IF (currentAccount.makeWithdrawal(amount) IS TRUE)
//A-1-7-02) ADD amount TO sumOfWithdrawals
//A-1-7-03) DISPLAY the withdrawal line using the following arguments: amount
//A-1-7-04) ELSE
///A-1-7-05) DEFINE variable overdraftFee of type double and ASSIGN it the value returned from a call of method currentAccount.getOvedraftFee
//A-1-7-06) ADD overdraftFee TO sumOfFees
//A-1-7-07) ADD amount TO sumOfOverdrafts
//A-1-7-08) DISPLAY the overdraft line using the following arguments: overdraftFee, amount
//A-1-7-09) END IF

//Exhibit A-1-8: 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 CheckingAccountPlus and amount of type double.
//A-1-8-01) IF (currentAccount.makeWithdrawal(amount) IS TRUE)
//A-1-8-02) ADD amount TO sumOfWithdrawals
//A-1-8-03) DISPLAY the withdrawal line using the following arguments: amount
//A-1-8-04) ELSE
//A-1-8-05) DEFINE variable creditCardAdvance of type double and ASSIGN it the value returned from a call of method
//A-1-8-06) currentAccount.getCreditCardAdv ance
//A-1-8-07) ADD creditCardAdvance TO sumOfCreditCardAdvances
//A-1-8-08) ADD currentAccount.getActualWithdrawal() TO sumOfWithdrawals
//A-1-8-09) DISPLAY the credit-card-advance line using the following arguments: currentAccount.getActualWithdrawal(),creditCardAdvance
//A-1-8-10) END IF

//Exhibit A-1-9: Pseudo code for Overloaded Method printBeginningBalance of
//Class CheckingAccountsTest
//This private static method has no return value, and has one parameter: currentAccount of type CheckingAccount.
//A-1-9-01) DISPLAY the beginning balance line using the following arguments: currentAccount , currentAccount.getAccountId(),
//A-1-9-02) currentAccount.getAccountType() and currentAccount.getBalance()

//Exhibit A-1-10: Pseudo code for Overloaded Method printBeginningBalance of
//Class CheckingAccountsTest
//This private static method has no return value, and has one parameter: currentAccount of type CheckingAccountPlus.
//A-1-10-01) DISPLAY the beginning balance line using the following arguments: currentAccount , currentAccount.getAccountId(),
//A-1-10-02) currentAccount.getAccountType() and currentAccount.getBalance()

//Exhibit A-1-11: Pseudo code for Overloaded Method printEndingBalance of
//Class CheckingAccountsTest
//This private static method has no return value, and has one parameter: currentAccount of type CheckingAccount.
//A-1-11-01) DISPLAY the ending balance line using the following arguments: "Account Totals," currentAccount.getAccountId(),
//A-1-11-02) currentAccount.getAccountType(), currentAccount.getBeginningBalance(), currentAccount.getDeposits(),
//A-1-11-03) currentAccount.getWithdrawals(), currentAccount.getFees(), currentAccount.getBalance() and
//A-1-11-04) currentAccount.getOverdrafts(), "? *"

//Exhibit A-1-12: Pseudo code for Overloaded Method printEndingBalance of
//Class CheckingAccountsTest
//This private static method has no return value, and has one parameter: currentAccount of type CheckingAccountPlus.
//A-1-12-01) DISPLAY the ending balance line using the following arguments: "Account Totals," currentAccount.getAccountId(),
//A-1-12-02) currentAccount.getAccountType(), currentAccount.getBeginningBalance(), currentAccount.getDeposits(),
//A-1-12-03) currentAccounts.getWithdrawals(), currentAccount.getBalance() and currentAccount.getSumOfCreditCardAdvances(),
//A-1-12-04) "? *"

//Exhibit A-2-2: Pseudo code for Constructor Method CheckingAccount of Class CheckingAccount
///This public method has no return value, and has four parameters: accountId of type String, firstName of type String, lastName of type String and balance of type double.
//A-2-2-01) ASSIGN accountId TO this.accountId
//A-2-2-02) ASSIGN firstName TO this.firstName
//A-2-2-03) ASSIGN lastName TO this.lastName
//A-2-2-04) IF (balance IS GREATER THAN OR EQUAL TO ZERO)
//A-2-2-05) ASSIGN balance TO this.balance
//A-2-2-06) ELSE
//A-2-2-07) ASSIGN ZERO TO this.balance
//A-2-2-08) END IF
//A-2-2-09) ASSIGN this.balance TO this.beginningBalance
//A-2-2-10) ASSIGN ZERO TO this.deposits
//A-2-2-11) ASSIGN ZERO TO this.withdrawals
//A-2-2-12) ASSIGN ZERO TO this.fees

//Exhibit A-2-3: Pseudo code for Method getAccountId of Class CheckingAccount
//This public method has a String return value, and has no parameters
//A-2-3-01) RETURN accountId
return accountId;
//Exhibit A-2-4: Pseudo code for Method getAccountType of Class CheckingAccount
//This public static method has a String return value, and has no parameters
//A-2-4-01) RETURN accountType
return accountType;
//Exhibit A-2-5: Pseudo code for Method getBalance of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-5-01) RETURN balance
return balance;
//Exhibit A-2-6: Pseudo code for Method getBeginningBalance of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-6-01) RETURN beginningBalance
return beginningBalance;
//Exhibit A-2-7: Pseudo code for Method getDeposits of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-7-01) RETURN deposits
return deposits;
//Exhibit A-2-8: Pseudo code for Method getFees of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-8-01) RETURN fees
return fees;
//Exhibit A-2-9: Pseudo code for Method getFirstName of Class CheckingAccount
//This public method has a String return value, and has no parameters
//A-2-9-01) RETURN firstName
return firstName;
//Exhibit A-2-10: Pseudo code for Method getLastName of Class CheckingAccount
//This public method has a String return value, and has no parameters
//A-2-10-01) RETURN lastName
return lastName;
//Exhibit A-2-11: Pseudo code for Method getOverdraftFee of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-11-01) RETURN overdraftFee
return overraftFee;
//Exhibit A-2-12: Pseudo code for Method getOverdrafts of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-12-01) RETURN overdrafts
return overdrafts;
//Exhibit A-2-13: Pseudo code for Method getWithdrawals of Class CheckingAccount
//This public method has a double return value, and has no parameters
//A-2-13-01) RETURN withdrawals
return withdrawals;
//Exhibit A-2-14: Pseudo code for Method makeDeposit of Class CheckingAccount
//This public method has no return value, and has one parameter: amount of type double
//A-2-14-01) CALL method setBalance, passing it the following argument: getBalance() + amount
//A-2-14-02) ADD amount TO deposits

//Exhibit A-2-15: Pseudo code for Method makeWithdrawal of Class CheckingAccount
//This public method has a Boolean return value, and has one parameter: amount of type double
//A-2-15-01) DEFINE double variable named balanceAfterWithdrawal and assign its value from the following expression: getBalance() - amount
//A-2-15-02) IF (balanceAfterWithdrawal IS GREATER THAN OR EQUAL TO ZERO)
//A-2-15-03) CALL method setBalance, passing it the following argument: getBalance() - amount
//A-2-15-04) ADD amount TO withdrawals
//A-2-15-05) RETURN TRUE
//A-2-15-06) ELSE
//A-2-15-07) CALL method setBalance, passing it the following argument: getBalance() - getOverdraftFee()
//A-2-15-08) ADD amount TO overdrafts
//A-2-15-09) ADD getOverdraftFee() TO fees
//A-2-15-10) RETURN FALSE
//A-2-15-11) END IF

//Exhibit A-2-16: Pseudo code for Method setBalance of Class CheckingAccount
//This public method has no return value, and has one parameter: amount of type double
//A-2-16-01) ASSIGN amount TO this.balance

//Exhibit A-2-17: Pseudo code for Method setWithdrawals of Class CheckingAccount
//This public method has no return value, and has one parameter: amount of type double
//A-2-17-01) ASSIGN amount TO this.withdrawals

//Exhibit A-2-18: Pseudo code for Method toString of Class CheckingAccount
//This public method has a String return value, and has no parameters
//A-2-18-01) RETURN the following expression : getLastName() + ",? " + getFirstName()

//Exhibit A-3-1: UML Class Diagram of Class CheckingAccountPlus

// This class extends class CheckingAccount, which makes class CheckingAccount the superclass
// and class CheckingAccountPlus the subclass. In other words, class CheckingAccountPlus
// inherits from class CheckingAccount, which means the class CheckingAccountPlus inherits all of
// the methods and fields of its superclass. A subclass can override methods in its superclass,
// which class CheckingAccountPlus is doing with its getAccountType and makeWithdrawal methods.

//CheckingAccountPlus
//-accountType : String = "Plus" // this field is final and static
//-actualWithdrawal : double
//-creditCardAdvance : double
//-sumOfCreditCardAdvances : double
//+"constructor" CheckingAccountPlus(accountId : String, firstName : String, lastName : String, balance : double)
//+getAccountType() : String // this method is static, and overrides method in class CheckingAccount
//+getActualWithdrawal() : double
//+getCreditCardAdvance() : double
//+getSumOfCreditCardAdvances() : double
//+makeWithdrawal(amount : double) : Boolean // this method is overrides method in class CheckingAccount
//-setCreditCardAdvance(amount : double)

//Exhibit A-3-2: Pseudo code for Constructor Method CheckingAccountPlus of
//Class CheckingAccountPlus
//This public method has no return value, and has four parameters: accountid of type String, firstName of type String, lastName of type String and balance of type double.
//A-3-2-01) Using keyword super, CALL the superclass' constructor, passing it the following arguments: accountId, firstName, lastName, balance
//A-3-2-02) ASSIGN ZERO TO this.actualWithdrawal
//A-3-2-03) ASSIGN ZERO TO this.creditCardAdvance
//A-3-2-04) ASSIGN ZERO TO this.sumOfCreditCardAdvances

//Exhibit A-3-3: Pseudo code for Method getAccountType of Class CheckingAccountPlus
//This public static method has a String return value, and has no parameters
//A-3-3-01) RETURN accountType

//Exhibit A-3-4: Pseudo code for Method getActualWithdrawal of Class CheckingAccountPlus
//This public method has a double return value, and has no parameters
//A-3-4-01) RETURN actualWithdrawal

//Exhibit A-3-5: Pseudo code for Method getCreditCardAdvance of Class CheckingAccountPlus
//This public method has a double return value, and has no parameters
//A-3-5-01) RETURN creditCardAdvance

//Exhibit A-3-6: Pseudo code for Method getSumOfCreditCardAdvances of Class CheckingAccountPlus
//This public method has a double return value, and has no parameters
//A-3-6-01) RETURN sumOfCreditCardAdvances

//Exhibit A-3-7: Pseudo code for Method makeWithdrawal of Class CheckingAccountPlus
//This public method has a Boolean return value, and has one parameter: amount of type double
//A-3-7-01) DEFINE double variable named balanceAfterWithdrawal and assign its value from the following expression: getBalance() - amount
//A-3-7-02) IF (balanceAfterWithdrawal IS GREATER THAN OR EQUAL TO ZERO)
//A-3-7-03) CALL method setBalance, passing it the following argument: getBalance() - amount
//A-3-7-04) CALL method setWithdrawals, passing it the following argument: getWithdrawals() + amount
//A-3-7-05) RETURN TRUE
//A-3-7-06) ELSE
//A-3-7-07) CALL method setBalance, passing it the following argument: ZERO
//A-3-7-08) CALL method setCreditCardAdvance, passing it the following argument: getCreditCardAdvance() - balanceAfterWithdrawal
//A-3-7-09) ASSIGN (amount + balanceAfterWithdrawal) TO actualWithdrawal
//A-3-7-10) CALL method setWithdrawals, passing it the following argument: getWithdrawals() + actualWithdrawal
//A-3-7-11) SUBTRACT balanceAfterWithdrawal FROM sumOfCreditCardAdvances
//A-3-7-12) RETURN FALSE
//A-3-7-13) END IF

//Exhibit A-3-8: Pseudo code for Method setCreditCardAdvance of Class CheckingAccountPlus
//This private method has no return value, and has one parameter: amount of type double
//A-3-8-01) ASSIGN amount TO this.creditCardAdvance

}//
}//
}
[ November 12, 2006: Message edited by: Jim Yingst ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I see at least one construction like this:

if (something)
// LONG COMMENT EXPLAINING WHAT IS TO BE DONE
else
// ANOTHER LONG COMMENT

an "else" is following an "if" without a body for the "if"; therefore the "else" is being taken as the body of the "if" -- in other words the compiler things the "else" starts a new statement. But it can't -- not without an "if" of its own.

One thing you could do to get this code to compile use empty braces to contain the comments -- i.e., like

if (something) {
// LONG COMMENT EXPLAINING WHAT IS TO BE DONE
} else {
// ANOTHER LONG COMMENT
}

The empty pairs of braces are acceptable as a "statement " here.

By the way, I feel for you, man -- what a way to learn how to code. Ouch.
[ November 11, 2006: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
mike hew
Greenhorn

Joined: Oct 26, 2006
Posts: 27
Thank you, after fixing the problem you show me, it fixed those problems, but since I added the rest of code I have over 100 errors out of 550 lines of code, but think I'll be back later after playing with it and figuring them out.

But again thank you!!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Mike, I've taken the unusual step of removing the [ code ] tags from your first post here. The reason is, your post contained multiple lines where there were hundreds of characters on one line. This was forcing the entire page to be incredibly wide, rending everything pretty much unreadable. Well, it's readable if you have to patience to scroll around a lot, but really, it should be the poster's responsibility to insert the occasional line break in their comments.

Also, you don't seem to have used any indentation in your code, which adds to the difficulty in reading it. Normally, using [ code ] tags would be necessary to preserve indentation. But sinc eyou didn't use any indentation, code tags are pretty much useless. Worse than useless in this case, since they preserved the hideously-overlong comment lines, forcing the whole page to be hundreds of characters wide.

So in the future, please: (1) use line breaks - don't write code (or comments) longer than, say, 80 characters, (2) use indentation in your code, and then (and only then) (3) use [ code ] tags. Thank you.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program Help
 
Similar Threads
Exeception in thread
Not compiling right?
Exception in thread
cannot find symbol
might not have been initialized