hey guys, im fairly new to this so feel free to tell me if i need to supply more info.
basically i need to write code to read in a text file and store different values in different variables, so for example i would read in:

bob
1.1
maths
1.2
physics
1.3
chemistry
jim
2.1
dance
2.2
programming
2.3
gym


ect ect

this would bassically be for code to allocate students into classes so the names are the teachers and the subjects things they teach, with the numbers representing class codes. if all i can get to work is reading in and storing the values appropriatly that would buy me time (im pretty close to the deadline!).

thanks for your help, sorry if my question has been asked before but i didn't find a good answer on google.

bigdan

Recommended Answers

All 4 Replies

Create the class
Open the file
Read a line
Place it in the variable
continue.

Pretty basic stuff.

waltP
sorry to be a pain but what is the code to itterate through the file doing different things with each line? is it any different from doing the same thing to every line?

waltP
sorry to be a pain but what is the code to itterate through the file doing different things with each line? is it any different from doing the same thing to every line?

No, it's no different.

Sorry, but what you are actually asking us to do is teach you how to do a loop, open a file, read a file, and create and store data into your class. This is a help forum, not a teach me forum. Your instructor should have taught you all the things I mentioned. Your job is to put them together to accomplish the project. Our job is to help you when you get stuck, not teach you from scratch.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.