Assignments

ASSIGNMENT 1 ASSIGNMENT 2 - ASSIGNMENT 3 

The purpose of the individual assignment is to encourage further practice for the topics covered in our book but not covered in class (due to time constraints) and to give you the opportunity to work on more comprehensive exercises than those covered in the book. Rather than giving you homework assignments centered on different topics, I prefer to give you homework assignments that build and refine a single solution. This semester's assignments will automate the calculation of a a house mortgage payment.

Assignment Submitting Standards:

  1. All assignments are due at the beginning of the class period.

  2. Late assignments will NOT be accepted.

  3. All assignments should be submitted in a 9x12 manila envelope with the cover letter statement attached (stapled, glued, taped) to the the outside of the envelope.

  4. Printed copy of your source code.
  5. The System Test plan completed and signed including printout of your output.

  6. A diskette with all the source code.

ASSIGNMENT 1: CSUS MORTGAGE Ver 1.0 top Solution: CSUSMortgageV1.zip

The purpose of this assignment is to provide you with a comprehensive exercise to practice the following material (Chapters 1, 2, and 3):

  1. Creating VB Projects

  2. Using basic controls

  3. Creating variables and constants

  4. Performing calculations

  5. Displaying message boxes

  6. Handling exceptions

Files Needed:

You need the following file to complete all assignments:

Interface Description:

Figure 1.1

  1. Name your project and solution CSUSMortgageV1.

  2. Form and application icon is KEY04.ICO found in the Microsoft Visual Studio .NET 2003 Graphics folder. KEY04.ICO

  3. Form should be centered on the screen (default).

  4. Form name and source code file name should be frmCSUSMortgage.

  5. Picture box displays the icon shown above.

  6. Only the 2 text boxes, the radio buttons, and the check box shall receive focus and the order should be as it shows on the form (top to bottom).

  7. Both text boxes are aligned to the right.

  8. Create a tool tip for the loan amount and interest rate text boxes. Tool tips should say "Please type the mortgage amount as an integer." and "Please type the interest rate as a decimal. For example, a 10% interest rate is 0.10 as a decimal.".

  9. 30 years should be the default loan years (default radio button).

  10. Interest rate text box has a default value of 0.0625.

  11. A single line should be used to separate the calculate button from the rest of the objects in the form.

  12. You should be able to press Alt+C to perform the calculation (in addition to pressing the calculate button).

  13. Label at the bottom has a light yellow background color and single border ( is used to display the result of the calculation). Label should always appear on the bottom of the window.

Implementation Description:

Class Diagram

  1. Declare the fields shown on the class diagram above.

  2. All radio button events have a similar logic (they just change the value of the mintLoanYears field).

  3. The check box event contains the appropriate code to change the value of the blnStateEmployee field.

  4. When the user clicks on the calculate button:

    • If the either of the text boxes are empty, message "Please type data for both Loan Amount and Interest Rate fields" is displayed at the result label.

    • Test box values are converted to the appropriate numeric data.

    • A state employee receives 0.001 discount off the interest rate (make the value a constant).

    • Mortgage Payment is calculated using the Pmt function. Payment is made at the end of the period with zero balance left at the and of the term (zero future value).

    • Mortgage Payment should be calculated and displayed in a currency format, as shown in Figure 1.

  5. Handle only the InvalidCastException.  If there are not numeric data in either text box, display the following dialog and clear the result label:

Figure 1.2

 

ASSIGNMENT 2: CSUS MORTGAGE Ver 2.0 top Solution: CSUSMortgageV2.zip

The purpose of this assignment is to provide you with a comprehensive exercise to practice the following material (Chapters 4, 5, 7, and 8):

  1. Making decisions

  2. Validating input

  3. Writing event procedures

  4. Creating Menus

  5. Writing functions

  6. Using loops

  7. Using arrays

Interface Description:

Figure 2.1

  1. Create the interface shown in Figure 2.1

  2. Menu hierarchy has the following menus: File/Exit, View/Amortization, View/Clear, Help/About. A separator used used between View/Amortization and View/Clear.

  3. In the details group box, all components are labels with Courier New font.

  4. The annual interest rate text box is disabled (cannot change content).

  5. Calculate button is disabled.

Implementation Description:

Class Diagram

  1. Create methods shown in the class diagram above:
  2. When home value and down payment text boxes are filled and are numeric, the calculate button is enabled. Also, the findInterestRate method is called to find and display the interest rate from the interest rate table. Show appropriate error messages if not numeric data is typed and disable the calculate button.
  3. Interest rate is calculated based on the following table (must create an array of arrays to search the table for the appropriate interest rate):
Amount is  But not over 5 year rate 15 year rate 30 year rate
0 100,000  0.0475  0.0525  0.065
100,000 250,000  0.045  0.05  0.0638
250,000 1,000,000  0.04125  0.04575  0.0625
1,000,000    0.0375  0.0425  0.06125
  1. Interest rate is discounted by 0.001 for state employees.
  2. When radio buttons or the employee check box is clicked, the new interest rate is automatically found and displayed.
  3. The calculate button calculates and displays all detail labels (monthly amounts).
    • Loan amount is Home value - Down payment
    • Payment and interest is the same calculation as assignment 1 (pmt function).
    • Taxes is 1.25% per year of the home value.
    • Insurance is charged only when the down payment is less than 20% of the home value. Insurance is 0.005 of the loan amount per year.
    • PITI is the sum of Payment, Interest, Taxes, and Insurance.
    • Gross Income to qualify is PITI/0.3
  4. File/Exit exits application.
  5. View/Clear sets the form to its initial state.
  6. Help/About shows the following message box:

Figure 2.2

  1. View/Amortization shows the Amortization report similar to the one shown in Figure 2.3 (only last page of the report is shown). To print the report:

Figure 2.3

  • Go to a loop for the number of months defined by the Loan Years variable. Inside the loop the logic for the data in each of the columns is the following:

    • Month: Is a serial number that starts from 1 and ends with the number of months in the Loan Years (Loan Years times 12)

    • Mortgage PMT: A constant payment for the entire loan period (calculated by the pmt function)

    • Interest PMT: The interest expense for each month (calculated by the ipmt function) using the loan balance

    • Monthly Equity: The equity gains for this month; is the difference between Mortgage PMT and Interest PMT

    • Total Equity: The accumulated equity (sum of previous Equities)

    • Loan Balance: Loan balance - Monthly Equity

  • If the calculate button has not been pressed and there is no PITI in label, the following message will be displayed:

Figure 2.4

  • formatMonthColumn function receives a month and returns a string with the month right-padded with spaces till the string becomes 5 characters long.
  • formatCurrencyColumn function receives a double amount and returns a string with the amount formatted as currency with spaces left-padded till the string becomes 14 characters long. If the formatted number does not fit in the 14 characters column size, the overflow symbol (##############) is displayed.
  • Both functions above are used to align the columns for the report.
  • Report is printed in Courier New font size 12. 
  • First 3 lines are printed in all pages of the report.

ASSIGNMENT 3: CSUS MORTGAGE Ver 3.0 top

The purpose of this assignment is to provide you with a comprehensive exercise to practice the following material (Chapter 6):

  1. Creating classes with constructors, properties, and methods

  2. Using the concepts of encapsulation and inheritance

  3. Creating new objects using a class

Interface Description:

  1. Same as assignment 2 (see Figure 2.1 thru 2.4)

Implementation Description:

  1. Create the 2 new classes shown in the class diagram below:

  1. Class InterestFinder has only one public method named findInterestRate. This method receives the Loan Amount, the Loan Years, and a Boolean indicating if this loan is for a state employee. Method returns the interest rate to the calling program.
  2. Class Loan properties have the following business restrictions:
    • Loan Amount cannot be less than $10K, Interest Rate cannot be less than zero, Loan Years cannot be zero or less. If incorrect values are used the ArgumentException must be thrown with the appropriate message. Error message should be displayed in a MessageBox notifying the user of the error.
  3. Class Loan has the following methods:
    • calculateMortgagePayment; calculates this loan's Payment and Interest (pmt function)
    • calculateInterest; calculates the monthly interest based on the loan balance (received as a parameter)
    • calculateMortgageInsurance; calculates the monthly mortgage insurance based on the Home Value and Down Payment amounts received as parameters
    • calculateIncomeToQualify; calculates the monthly gross income to qualify for this loan based on the PITI amount received as a parameter

    NOTE: All methods above have the same functionality as Assignment 2

  4. Modify Assignment 2 interface to use the InterestFinder and Loan classes to perform calculations.