Iterations - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Iterations

Description:

Create a program that calculates commissions on car sales. ... After all the sale amounts have been entered, the program determines and outputs ... – PowerPoint PPT presentation

Number of Views:138
Avg rating:3.0/5.0
Slides: 14
Provided by: annwi
Category:
Tags: iterations

less

Transcript and Presenter's Notes

Title: Iterations


1
Iterations
  • VB .NET Module 4

2
Types of Loops
  • Event-driven
  • Determinate
  • Indeterminate

3
Using Do While
  • Count 0
  • Do While X gt 1
  • X X / 2
  • Count Count 1
  • Loop

4
Using Do Until
  • Count 0
  • Do
  • X X / 2
  • Count Count 1
  • Loop until X lt 1

5
For / Next Loops
  • For Count 1 to 10
  • X X / 2
  • Next Count

6
Application.DoEvents
  • Sub btnGO_Click
  • Dim intCounter as Integer 1
  • btnGO.enabled false
  • Do While intCounter lt 500000
  • Application.DoEvents()
  • intCounter intCounter 1
  • Loop
  • btnGO.enabled True

7
InputBox Function
strName InputBox(Enter name, Name Report)
8
ListBox Control
lstNames.Items.Add(strName)
9
Demo 1 Grade Calculator Problem Statement
Rework the grading program so that the user
enters the number of scores and is then asked for
the students scores. After all of the scores
have been entered, the program then calculates
the average and determines the students grade.
10
Demo 1 Grade Calculator Flowchart
11
Demo 2 Commissions Problem Statement
Create a program that calculates commissions on
car sales. The user inputs the sales amount and
the program calculates and lists the commission.
If the sale is 20,000 or less, the commission is
3 of the sale. If the sale is above 20,000, the
commission is 5 of the sale. After all the sale
amounts have been entered, the program determines
and outputs the average sale price, the high
sales price, and the low sales price. The end of
the sale amounts is indicated by entering 0.
12
Demo 2 Commissions FlowChart
A
Start
Count Count 1
B
Get Sale Price
Y
High? Low?
HighPrice Sale Price
End
Y
C
N
LowPrice Sale Price
N
Commission SalePrice .05
Y
gt20,000
C
B
Calculate Average
N
Commission SalePrice .03
Output
End
A
13
Demo 3 Depreciation Problem Statement
Straight-line depreciation is the simplest way to
calculate the depreciation of an asset. Write a
program that uses this method to calculate and
display the depreciation of an asset over its
lifetime, given the initial value of the asset
and its projected useful life-span. The
depreciation calculation is Depreciation
Depreciation Basis (initial value) / Useful Life
14
Demo 3 Depreciation Flowchart
Start
Get value, lifespan
Calculate Depreciation
Display Depreciation
Last Year?
N
Y
End
Write a Comment
User Comments (0)
About PowerShow.com