| | |
help with assignment
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
You could create a function that accepts a reference to a student and outputs it's data?
cpp Syntax (Toggle Plain Text)
void output_student(Student &stud){ //put the output code here } //.... int main(){ //loop each of your students here, one loop for reading in the data, the other one for outputting the data }
•
•
Join Date: Feb 2009
Posts: 25
Reputation:
Solved Threads: 0
but for the multiple subjects its correct for me to have the multiple inputs??
C++ Syntax (Toggle Plain Text)
// 1st subject inFile >> code[i]; inFile >> cu[i]; inFile >> pf[i]; //subject2 inFile >> codel[i]; inFile >> cul[i]; inFile >> pfl[i]; //subject3 inFile >> codell[i]; inFile >> cull[i]; inFile >> pfll[i]; //subject4 inFile >> codelll[i]; inFile >> culll[i]; inFile >> pflll[i];
No, student already has 4 subjects: use those.
cpp Syntax (Toggle Plain Text)
Student::Subjects::setVar();
•
•
Join Date: Feb 2009
Posts: 25
Reputation:
Solved Threads: 0
do u mean this?
sorry if i'm being dumb...
C++ Syntax (Toggle Plain Text)
Student::subjects::students[4]
sorry if i'm being dumb...
Last edited by halfnode; Apr 16th, 2009 at 8:05 am.
Errr, ignore that last part. Sometimes I'm unclear.
I meant something like that. That's the "input" loop. Now, as you can see, this one is for subjects, but you should also create one for students for their variables. Same goes for output. If you don't know how, first write the code for reading in 1 student, then simply loop that.
cpp Syntax (Toggle Plain Text)
Student student; for(int subject = 0; subject < 4; subject++){ string code; int cu; char pass_or_fail; inFile >> code; inFile >> cu; inFile >> pass_or_fail; //subject == loop variable subjects[subject].setCode(code); subjects[subject].setCU(cu); subjects[subject].setPF(pass_or_fail); }
I meant something like that. That's the "input" loop. Now, as you can see, this one is for subjects, but you should also create one for students for their variables. Same goes for output. If you don't know how, first write the code for reading in 1 student, then simply loop that.
•
•
Join Date: Feb 2009
Posts: 25
Reputation:
Solved Threads: 0
ya ok. i can get the name to be displayed now i just have to count the scores and display it.
but something tells me that i'm inserting the code,cu and pf wrongly.
but something tells me that i'm inserting the code,cu and pf wrongly.
C++ Syntax (Toggle Plain Text)
i = 0; k = 0; while( (ch = inFile.peek()) != EOF) { k = i; inFile >> name; students[k].setName(name); for(k = 0; k < 4; k++){ inFile >> code; inFile >> cu; inFile >> pf; //subject == loop variable students[k].setSCode(code,k); students[k].setSCU(cu,k); students[k].setSpf(pf,k); }
Last edited by halfnode; Apr 16th, 2009 at 9:33 am.
![]() |
Similar Threads
- Java Assignment Help Needed!!!!!!!!!! (Java)
- Help needed with VB Assignment (Visual Basic 4 / 5 / 6)
- Many Errors while doing this assignment (C)
- I need help on my 'address book' assignment! (C++)
Other Threads in the C++ Forum
- Previous Thread: A Curious Thing...
- Next Thread: Fraction Problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





