Tutorial 9 - Car Payment Calculator Application Introducing the while Repetition Statement Outline 9.1 Test-Driving the Car Payment Calculator Application.

Slides:



Advertisements
Similar presentations
Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Advertisements

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
Programming with Microsoft Visual Basic 2008 Fourth Edition
Programming with Microsoft Visual Basic th Edition
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
 Control structures  Algorithm & flowchart  If statements  While statements.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
CHAPTER SIX Loop Structures.
CHAPTER 6 Loop Structures.
CHAPTER SIX.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Shipping Hub Application Introducing Generic Collections, LINQ, For Each...Next.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
Chapter 12: How Long Can This Go On?
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Chapter 6: The Repetition Structure
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Loop.  While Loop  Do-while Loop  For Loop Continue Statement Conclusion Loop Loop.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
Dale Roberts Program Control using Java - Repetition Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 5A Repetition (Concepts)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
Java™ How to Program, Early Objects Version, 8/e © by Pearson Education, Inc. All Rights Reserved.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 8.1 Test-Driving the Car Payment Calculator.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 15 – Fund Raiser Application Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 10.1 Test-Driving the Interest Calculator.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Enhanced Car Payment.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 11.1 Test-Driving the Interest Calculator Application 11.2 Essentials of Counter-Controlled Repetition.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhanced Car Payment Calculator Application Introducing Exception Handling.
Tutorial 14 – Shipping Time Application Using DateTimes and Timers
Microsoft Excel.
Chapter 4 The If…Then Statement
while Repetition Structure
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Value-Returning Functions
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Chapter 5: Loops and Files.
Excel Formatting Rules
Chapter 4 – Control Structures Part 1
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Learning About the Loop Structure (continued)
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Microsoft Visual Basic 2005: Reloaded Second Edition
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Chapter (3) - Looping Questions.
CIS 16 Application Development Programming with Visual Basic
Chapter 5 – Control Structures: Part 2
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
Presentation transcript:

Tutorial 9 - Car Payment Calculator Application Introducing the while Repetition Statement Outline 9.1 Test-Driving the Car Payment Calculator Application 9.2 while Repetition Statement 9.3 Constructing the Car Payment Calculator Application 9.4 Wrap-Up

In this tutorial, you will learn to: Objective In this tutorial, you will learn to: Use the while repetition statement to execute statements in a program repeatedly. Use counter-controlled repetition. Display information in ListBoxes.

9.1 Test-Driving the Car Payment Calculator Application

9.1 Test-Driving the Car Payment Calculator Application Figure 9.1 Car Payment Calculator application before data has been entered. ListBox control

9.1 Test-Driving the Car Payment Calculator Application Figure 9.2 Car Payment Calculator application after data has been entered. Input data Click Calculate Button

9.1 Test-Driving the Car Payment Calculator Application Figure 9.3 Car Payment Calculator application displaying calculation results. Results displayed in tabular format

9.2 while Repetition Statement Loop-continuation condition While loop-continuation condition remains true, loop statement executes its body repeatedly When loop-continuation condition becomes false, loop terminates Code example: int intProduct = 3; while ( intProduct <= 50 ) { intProduct *= 3; }

9.2 while Repetition Statement Figure 9.4 while repetition statement UML activity diagram. [ intProduct <= 50 ] > triple product value merge decision Corresponding C# statement: *= 3;

9.3 Constructing the Car Payment Calculator Application

9.3 Constructing the Car Payment Calculator Application

9.3 Constructing the Car Payment Calculator Application Figure 9.6 Car Payment Calculator application’s Form in design mode.

9.3 Constructing the Car Payment Calculator Application Figure 9.7 ListBox added to Car Payment Calculator application’s Form. ListBox’s control name displayed in design view ListBox control Change the Name property

9.3 Constructing the Car Payment Calculator Application Figure 9.8 Rearranging and commenting the ListBox control declaration.

9.3 Constructing the Car Payment Calculator Application Adding code to the event handler Clearing the ListBox Call method Clear on property Items Items property returns an object containing items in ListBox

9.3 Constructing the Car Payment Calculator Application Figure 9.9 Clearing the contents of a ListBox.

9.3 Constructing the Car Payment Calculator Application Adding a header to the ListBox Call method Add Escape sequences \t

9.3 Constructing the Car Payment Calculator Application Figure 9.10 Adding a header to a ListBox.

9.3 Constructing the Car Payment Calculator Application

9.3 Constructing the Car Payment Calculator Application Figure 9.12 Variables for the Car Payment Calculator application. Variables to store the length of the loan Variables to store user input Variables to store calculation results • Variable declarations

9.3 Constructing the Car Payment Calculator Application Figure 9.13 Retrieving input in the Car Payment Calculator application. Retrieving input Use Int32.Parse and Double.Parse methods Divide interest rate by 100

9.3 Constructing the Car Payment Calculator Application Calculating values used in the calculation Subtract down payment from price Monthly interest rate is interest divided by 12

9.3 Constructing the Car Payment Calculator Application Figure 9.14 Determining amount borrowed and monthly interest rate.

9.3 Constructing the Car Payment Calculator Application Setting the loop-continuation condition Counter-controlled repetition Uses a counter variable Also called definite repetition

9.3 Constructing the Car Payment Calculator Application Figure 9.15 Loop-continuation condition.

9.3 Constructing the Car Payment Calculator Application Figure 9.16 Converting the loan duration from years to months. Add the length of the loan in months

9.3 Constructing the Car Payment Calculator Application Calculate monthly payment amount Use given formula Type Decimal stores monetary values Use the Convert.ToDecimal method

9.3 Constructing the Car Payment Calculator Application Figure 9.17 Calculating the monthly payment

9.3 Constructing the Car Payment Calculator Application Displaying the result Use method Add Use method String.Format to display values in currency format

9.3 Constructing the Car Payment Calculator Application Figure 9.18 Displaying the number of months and the amount of each monthly payment.

9.3 Constructing the Car Payment Calculator Application Increment the counter Add one to the counter Will terminate the loop when value becomes 6

9.3 Constructing the Car Payment Calculator Application Figure 9.19 Incrementing the counter.

CarPayment-Calculator.cs (1 of 6)

CarPayment-Calculator.cs (2 of 6) Declaration for a ListBox control

CarPayment-Calculator.cs (3 of 6)

CarPayment-Calculator.cs (4 of 6) Using the Clear method of property Items of a ListBox Using the Add method of property Items of a ListBox

CarPayment-Calculator.cs (5 of 6) Using a while repetition statement Using the Math.Pow method Incrementing the counter

CarPayment-Calculator.cs (6 of 6)