{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Slides - Chapter 9

Slides - Chapter 9 - Chapter9 1 BMGT302 BusinessApplication...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 9 Structures and Sequential Files BMGT 302 Business Application  Programming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Structures Structure  statement : used to create your own data  type User-defined data types   (or  structures ): data types  created by using the Structure statement Member variables : variables defined within a  structure Structure can include member variables of: Any standard data types Other structure types Used to group related items into one unit Usually declared in the form’s Declarations section 2
Background image of page 2
Structures (cont'd.) How to define a structure 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Declaring a Structure Variable Structure statement only creates the data type It does not reserve memory locations Structure variables : variables declared using a  structure How to declare a structure variable 4
Background image of page 4
Declaring a Structure Variable (cont'd.) Refer to an entire structure in code using its name Refer to a  member variable  using the structure name  with the dot operator and the member variable name structureVariable.memberVariable Member access operator (a period) Member variables can be used like any other  variables 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Declaring a Structure Variable (cont'd.) How to use a member variable 6
Background image of page 6
Passing a Structure Variable  to a Procedure Sample application Determine the amount of water required to fill a  rectangular pool Program without using a structure Sample run of the Willow Pools application 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Code for the  Willow Pools  application  (without a  structure) 8
Background image of page 8
Code for the Willow Pools application (with a structure) 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Passing a Structure Variable to a Procedure  (cont'd.) When you pass a structure variable to a  procedure, all of its member variables are  automatically passed Sample application using a structure: Uses less code to pass a structure variable to a  procedure Stores all of the data in a single unit 10
Background image of page 10
Creating an Array  of Structure Variables Use a one-dimensional array of structure variables Each element in the array is a structure variable Sample run of the Treasures Gift Shop application 11
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Partial code for the Treasures Gift Shop application 12
Background image of page 12
Partial code for the Treasures Gift Shop application (cont’d.) Creating an Array  of Structure Variables (cont’d.) 13
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
In-class exercise Demo 9-1 14
Background image of page 14
File Types  Output files : files to which information is written Input files : files that are read by the computer Sequential access files  ( text files ) composed of text that are both read and written  sequentially, one line at a time Random access files Data can be accessed in any order Can jump to any item without reading the preceding items 15 Think of songs on a  tape and an iPod
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}