Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator.

Similar presentations


Presentation on theme: "COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator."— Presentation transcript:

1 COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator

2 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Sample Development: Loan Calculator *Problem Statement Write a loan calculator that computes monthly payments and total payments for a loan based on loan amount, annual interest rate and loan period *Program flow: Get three input values: loanAmount, interestRate, and loanPeriod. Compute the monthly and total payments. Output the results. *What classes do we need?

3 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. UML Diagram for Loan Calculator

4 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Loan Calculator *Steps in implementation: 1.Start with code to accept three input values. 2.Add code to output the results. 3.Add code to compute the monthly and total payments. 4.Update or modify code and tie up any loose ends.

5 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Loan Calculator: Step 1 *Input Three Data Values *Choices: Call showInputDialog method for each of three input values: Use a Scanner *Question: What format should the data be in? loan amount - use double for dollars and cents annual interest rate - percentage needs to be a double loan period - usually an even number of years so use an int

6 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 2: Output Values *We must determine an appropriate format to display the computed results, so that the results will be comprehensible to the user. How much information do we need to show? *For now, put placeholders in the position the actual results will go

7 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Possible D isplay Formats *Only the computed values displayed Monthly payment:$ 143.47 Total payment:$ 17216.50 * Input values displayed. For Loan Amount:$ 10000.00 Annual Interest Rate:12% Loan Period(years):10 Monthly payment is$ 143.47 Total payment is$ 17216.50

8 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 3: Compute Loan Amount *Complete the program by implementing the formula derived in the design phase. *We must convert the annual interest rate (input value) to a monthly interest rate (per the formula) the loan period to the number of monthly payments.

9 COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 4: Finishing Up *Finalize the program by making necessary modifications or additions. *We will add a program description and format the monthly and total payments to two decimal places.


Download ppt "COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator."

Similar presentations


Ads by Google