Hey guys, I make this system to record carry marks for student and I'm having this difficult time to find what I did wrong with output for Carry Mark Summary. It have problem showing up the first student's carry mark (I test to insert 2 student profile) but only the 2nd student came up. Can you guys have a look for me please?
NEED HELP URGENTLY
Your data structure is very complicated so it's difficult to come up with a quick fix (See EDIT below - maybe not needed) except to say whatever you do you need to have the following process in mind:
1) load the complete list(s) of all records from the file
2) add/amend items on the the list(s) as required
3) save the complete list(s) of all items back to the file
From my test and what you say, each line of the txt file excluding the headings represents a single Student_Record. That might be a good name for a class.
EDIT:
STUDENT ID NO QUIZ ASSIGNMENT MD TEST LAB EXE TOTAL CM
567 1.50 18.00 19.50
STUDENT ID NO QUIZ ASSIGNMENT MD TEST LAB EXE TOTAL CM
NA678 17.60 17.60
to find what I did wrong with output for Carry Mark Summary
Use the debugger to trace through the code so see what's happening and the values of variables. When things deviate from that expected, you're found a problem. Repeat until the program works OK. If you find a problem but don't understand it, then post the relevant code and an explanation of the issue.
I don't know if this is your specific problem, but it is a problem.
Take a look at line 523. You're using your global x as a loop variable which wipes out the value of x which you appear to be using as a count of the number of students.
[edit] You have removed this for loop is the latest code on cpp.sh.
Your global x is a very poor practice for two reasons:
1) You should avoid the use of globals for just this reason.
2) x is poorly named. Had you called it num_students for example, this naming conflict would never have occurred.
Some other minor comments (not a complete list):
Line 34: score is a global. You modify score all over the place. Poor practice.
For example, line 46 depends on the fact that score has already been correctly set.
score should be local to the function where it is set and passed in as an argument.
It's not clear how much you've learned about classes.
Since you're posting in the General forum and not the Beginners forum,
I assume you've had a reasonable exposure to classes.
Lines 10,18,28: Your member variables are public in your three classes. Again, poor practice.
Member variables should be private and you should have public functions to perform operations on them.
Lines 44-47, 64-67, 84-87, 104-107: You initialize node in numerous places.
You should do it in one place. i.e. Assessment's constructor.
Lines 50-55, 70-75, 90-95, 110-115: You walk Assessment's linked list in multiple places in order to add a node.
You should do this ONCE in an Assessment member function.
Line 24: List appears to be an array of up to 100 Students.
You increment x at line 642. You never check to see if x exceeds 100.
Line 122: Why are you creating a new List every time you want want to add a student?
You should have a single List of students.