help with college stats program
help with college stats program
I have to create a program that retrieves information from a data file.
Ex. of questions that have to be answered:
How many colleges/universities are in NC?
what school has the most faculty members (all ranks)?
The data file has information on division I II and III colleges in the U.S. and is saved in a txt file.
The character positions of the data found within this file has been organized in the following manner:
1-5 FICE (Federal ID number)
7-37 College name
38-39- State (postal code)
40-43 Type (I, IIA, or IIB)
I need help trying to figure out how to at least start this program, so that when a question is asked the info is read from the file. My code so far looks like this
CLS
FILE$ = "A:\college.txt"
OPEN FILE$ FOR INPUT AS #1
PRINT "Search our database for information on colleges"
DO WHILE NOT EOF(1)
INPUT #1, FICE, COLLEGE$, STATE$
IF STATE$ = "NC" THEN
LET s = s + 1
END IF
PRINT s
Please help
Ex. of questions that have to be answered:
How many colleges/universities are in NC?
what school has the most faculty members (all ranks)?
The data file has information on division I II and III colleges in the U.S. and is saved in a txt file.
The character positions of the data found within this file has been organized in the following manner:
1-5 FICE (Federal ID number)
7-37 College name
38-39- State (postal code)
40-43 Type (I, IIA, or IIB)
I need help trying to figure out how to at least start this program, so that when a question is asked the info is read from the file. My code so far looks like this
CLS
FILE$ = "A:\college.txt"
OPEN FILE$ FOR INPUT AS #1
PRINT "Search our database for information on colleges"
DO WHILE NOT EOF(1)
INPUT #1, FICE, COLLEGE$, STATE$
IF STATE$ = "NC" THEN
LET s = s + 1
END IF
PRINT s
Please help
What you need is random access files.
The best solution for you problem is random access files. You should read some good tutorial on random access files.
Here is a code that might help. This is for reading data:
CLS
TYPE URec
FICE AS SINGLE
COLLEGE AS STRING * 90
STATE AS STRING * 50
END TYPE
DIM orec AS URec
INPUT "Number of record>", rec%
OPEN "college.txt" FOR RANDOM AS #1 LEN = 145
GET #1, rec, orec
PRINT "FICE: "; orec.FICE
PRINT "COLLEGE: "; orec.COLLEGE
PRINT "STATE: "; orec.STATE
CLOSE #1
And this is for inputting data:
CLS
TYPE URec
FICE AS SINGLE
COLLEGE AS STRING * 90
STATE AS STRING * 50
END TYPE
DIM orec AS URec
FILE$ = "college.txt"
OPEN FILE$ FOR RANDOM AS #1 LEN = 145
INPUT "FICE>", orec.FICE
LINE INPUT "College>", orec.COLLEGE
LINE INPUT "State>", orec.STATE
PUT #1, , orec
CLOSE #1
I don't think this code answers your question exactly, but when you learn how to use random access files, you will be able to modify it.
?Y12
Here is a code that might help. This is for reading data:
CLS
TYPE URec
FICE AS SINGLE
COLLEGE AS STRING * 90
STATE AS STRING * 50
END TYPE
DIM orec AS URec
INPUT "Number of record>", rec%
OPEN "college.txt" FOR RANDOM AS #1 LEN = 145
GET #1, rec, orec
PRINT "FICE: "; orec.FICE
PRINT "COLLEGE: "; orec.COLLEGE
PRINT "STATE: "; orec.STATE
CLOSE #1
And this is for inputting data:
CLS
TYPE URec
FICE AS SINGLE
COLLEGE AS STRING * 90
STATE AS STRING * 50
END TYPE
DIM orec AS URec
FILE$ = "college.txt"
OPEN FILE$ FOR RANDOM AS #1 LEN = 145
INPUT "FICE>", orec.FICE
LINE INPUT "College>", orec.COLLEGE
LINE INPUT "State>", orec.STATE
PUT #1, , orec
CLOSE #1
I don't think this code answers your question exactly, but when you learn how to use random access files, you will be able to modify it.
?Y12
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
Hi ludacris,
You might be interested in reading my Random Access File Tutorial I wrote for the QB express Magazine #6 ...
http://www.petesqbsite.com/sections/exp ... ccessfiles
There's this issue of a grey rectangle hiding everything in firefox, I suggest you open it in Internet Explorer .
or go to my website http://www.ascii-world.com and click on intermediate techniques (menu on the left) and you'll see it there too, and the forumatting there doesn't cause this hiding grey area ...choice is yours .
Hope this helps
You might be interested in reading my Random Access File Tutorial I wrote for the QB express Magazine #6 ...
http://www.petesqbsite.com/sections/exp ... ccessfiles
There's this issue of a grey rectangle hiding everything in firefox, I suggest you open it in Internet Explorer .
or go to my website http://www.ascii-world.com and click on intermediate techniques (menu on the left) and you'll see it there too, and the forumatting there doesn't cause this hiding grey area ...choice is yours .
Hope this helps
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Re: help with college stats program
you forgot TYPE (I, IIA or IIB) in your input#1 line
that could cause some errors...
1-5 FICE (Federal ID number)
7-37 College name
38-39- State (postal code)
40-43 Type (I, IIA, or IIB)
CLS
FILE$ = "A:\college.txt"
OPEN FILE$ FOR INPUT AS #1
PRINT "Search our database for information on colleges"
DO WHILE NOT EOF(1)
INPUT #1, FICE, COLLEGE$, STATE$
IF STATE$ = "NC" THEN
LET s = s + 1
END IF
PRINT s
Please help[/quote]
that could cause some errors...
1-5 FICE (Federal ID number)
7-37 College name
38-39- State (postal code)
40-43 Type (I, IIA, or IIB)
CLS
FILE$ = "A:\college.txt"
OPEN FILE$ FOR INPUT AS #1
PRINT "Search our database for information on colleges"
DO WHILE NOT EOF(1)
INPUT #1, FICE, COLLEGE$, STATE$
IF STATE$ = "NC" THEN
LET s = s + 1
END IF
PRINT s
Please help[/quote]