Records are an easy way to create a single variable that can hold several different values. For example, consider the problem of storing a mailing address. The address has many parts, but is conceptually one unit.
I have created a text file with some fake addresses. This file contains six addresses.
The code provided will create a record called "Address
"
that contains four fields:
String
)
String
)
String
)
int
)
Then, the code provided creates a variable of type Address
and reads the values from the first address in the text file into the four
fields of the record.
It does the same thing for a second and third address. Finally, it prints out the three addresses on the screen.
191 Marigold Lane, Miami, FL 33179 3029 Losh Lane, Crafton, PA 15205 4939 Holt Street, Lake Worth, FL 33463
Assignments turned in without these things will receive half credit or less.
Address
variables. Change the code to read and display two more addresses
from the file.
©2013 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.