19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SUMMARY<br />

1. A fixed-length string is a variable declared with a statement of the form Dim<br />

var As String * n. The value of var is always a string of n characters.<br />

2. A record is a composite user-defined data type with a fixed number of fields<br />

each of which can be of most data types. Type statements [in this text appearing<br />

in the (Declarations) section of a BAS Module] define record types <strong>and</strong><br />

Dim statements are used to declare a variable to be of that type.<br />

3. After a record type has been specified, the associated r<strong>and</strong>om-access file is an<br />

ordered collection of record values numbered 1, 2, 3, <strong>and</strong> so on. Record values<br />

are placed into the file with Put statements <strong>and</strong> read from the file with Get<br />

statements. At any time, the value of LOF(n) / Len(recordVar) is the number of<br />

the highest record value in the file <strong>and</strong> the value of Loc is the number of the<br />

record value most recently accessed by a Put or Get statement.<br />

PROGRAMMING PROJECTS<br />

1. Balance a Checkbook. Write an interactive program to request information<br />

(payee, check number, amount, <strong>and</strong> whether or not the check has cleared) for<br />

each check written during a month <strong>and</strong> store this information in a r<strong>and</strong>om file.<br />

The program should then request the balance at the beginning of the month <strong>and</strong><br />

display the current balance <strong>and</strong> the payee <strong>and</strong> amount for every check still outst<strong>and</strong>ing.<br />

2. A teacher maintains a r<strong>and</strong>om-access file containing the following information<br />

for each student: name, social security number, grades on each of two hourly<br />

exams, <strong>and</strong> the final exam grade. Assume the r<strong>and</strong>om-access file<br />

GRADES.TXT has been created with string fields of lengths 25 <strong>and</strong> 11 <strong>and</strong><br />

three numeric fields, <strong>and</strong> all the names <strong>and</strong> social security numbers have been<br />

entered. The numeric fields have been initialized with zeros. Write a program<br />

with the five comm<strong>and</strong> buttons “Display First Student,” “Record Grade(s) &<br />

Display Next Student,” “Locate Student,” “Print Grade List,” <strong>and</strong> “Done” to<br />

allow the teacher to do the following.<br />

(a) Enter all the grades for a specific exam.<br />

(b) Locate <strong>and</strong> display the record for a specific student so that one or more<br />

grades may be changed.<br />

(c) Print a list of final grades that can be posted. The list should show the last<br />

four digits of the social security number, the grade on the final exam, <strong>and</strong><br />

the semester average of each student. The semester average is determined<br />

by the formula (exam1 + exam2 + 2 * finalExam) / 4.<br />

Summary 255

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!