ADT and Linked List implementation using C++

hey, can someone help me with add a code on show all the carrymarks and show the highest carrymarks. and also, it got lots of error on it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
  #include <fstream>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

class Assessment {
public:
	string type;
	float mark;
	Assessment* next;
};

class Student {
public:
	string ID;
	float cmark;
	Assessment* head;
};

class List {
public:
	int index;
	Student record[100];
};

void pushStudent(string new_ID, float new_cmark) {
	Student* new_student = new Student();
	new_student->ID = new_ID;
	new_student->cmark = new_cmark;
}

void push_quiz(Student** head_reference, float new_mark) {
	Assessment* new_assessment = new Assessment();
	new_assessment->type = "Quiz";
	new_assessment->mark = new_mark;
}

float perncentageQuiz(float new_mark) {
	float percent;
	percent = (new_mark / 40) * 100;
	return percent;
}

void push_midterm(Assessment** head_reference, float new_mark) {
	Assessment* new_assessment = new Assessment();
	new_assessment->type = "Mid Term";
	new_assessment->mark = new_mark;
}

float percentageMidterm(float new_mark) {
	float percent;
	percent = (new_mark / 40) * 100;
	return percent;
}

void push_assigment(Assessment** head_reference, float new_mark) {
	Assessment* new_assessment = new Assessment();
	new_assessment->type = "Asssigment";
	new_assessment->mark = new_mark;
}

float percentageAssignment(float new_mark) {
	float percent;
	percent = (new_mark / 40) * 100;
	return percent;
}

void push_labExercise(Assessment** head_reference, float new_mark) {
	Assessment* new_assessment = new Assessment();
	new_assessment->type = "Lab exercise";
	new_assessment->mark = new_mark;
}

float percentageLabExercise(float new_mark) {
	float percent;
	percent = (new_mark / 14) * 100;
	return percent;
}

float carryMark() {
	float cmark;
}

int main() {
	List* list = NULL;
	Student* std = NULL;
	Assessment* ass = NULL;

	int i;
	int option1, option2, option3 = 0;
	string student_ID;
	float markq, markq2;
	float totalmark;
	string type;

	cout << "Carry Mark Program\n" << endl;

	do
	{
		cout << "1. Add new student\n";
		cout << "2. Update Assessment\n";
		cout << "3. Carry Mark Summary\n";
		cout << "4. Carry Mark Summary (save to File)\n";
		cout << "5. Exit\n";
		cout << "Select Menu: ";
		cin >> option1;
		if (option1 == 1)
		{
			system("CLS");
			cout << "Enter student ID: ";
			getline(cin, student_ID);

			do
			{
				cout << "Assessment menu:\n";
				cout << "1. Quiz\n";
				cout << "2. Assignment\n";
				cout << "3. Mid Term Test\n";
				cout << "4. Lab Exercise\n";
				cin >> option2;

				if (option2 == 1)
				{
					cout << "Enter Quiz mark(40): ";
					cin >> markq;
					push_quiz(:ass, markq);
					cout << "Perncentage of Quiz is:" << perncentageQuiz(markq) << "%" << endl;
				}
				else if (option2 == 2)
				{
					cout << "Enter Assigment mark (10): ";
					cin >> markq;
					push_quiz(:ass, markq);
					cout << "Perncentage of Quiz is:" << percentageAssignment(markq) << "%" << endl;
				}
				else if (option2 == 3)
				{
					cout << "Enter Mid Term Mark mark(40): ";
					cin >> markq;
					push_quiz(:ass, markq);
					cout << "Perncentage of Quiz is:" << percentageMidterm(markq) << "%" << endl;
				}
				else if (option2 == 4)
				{
					cout << "Enter lab Exercise mark(14): ";
					cin >> markq;
					push_quiz(:ass, markq);
					cout << "Perncentage of Quiz is:" << percentageLabExercise(markq) << "%" << endl;
				}

				cout << "Add another Assessment [Y/N]: ";
				cin >> option3;
				if (option3 == 'Y' || option3 == 'y')
				{
					continue;
				}
				else
				{
					break;
				}
			}
		else if (option1 == 2) {
			system("cls");
			cout << "Enter student ID: " << endl;
			getline(cin, student_ID);
			list->record[list->index] = new pustStudent(student_ID, totalmark);
			do
			{
				cout << "Assessment menu\n";
				cout << "1. Quiz\n";
				cout << "2. Assignment\n";
				cout << "3. Mid Term\n";
				cout << "4. Lab Exercise\n";
				cin >> option2;

				if (option2 == 1)
				{
					cout << "Current percentage of Quiz is: " << perncentageQuiz(markq) << "%\n" << endl;
					cout << "Enter Quiz mark(40): ";
					cin >> markq2;
					push_quiz(:ass, markq2);
					cout << "Perncentage of Quiz is:" << perncentageQuiz(markq2) << "%" << endl;
				}
				else if (option2 == 2)
				{
					cout << "Current percentage of Assignment is: " << percentageAssignment(markq) << "%\n" << endl;
					cout << "Enter Assigment mark (10): ";
					cin >> markq2;
					push_quiz(:ass, markq2);
					cout << "Perncentage of Quiz is:" << percentageAssignment(markq2) << "%" << endl;
				}
				else if (option2 == 3)
				{
					cout << "Current percentage of Mid Term is: " << percentageMidterm(markq) << "%\n" << endl;
					cout << "Enter Mid Term Mark mark(40): ";
					cin >> markq2;
					push_quiz(:ass, markq2);
					cout << "Perncentage of Quiz is:" << percentageMidterm(markq2) << "%\n" << endl;
				}
				else if (option2 == 4)
				{
					cout << "Current percentage of Lab Exercise is: " << percentageLabExercise(markq) << "%\n" << endl;
					cout << "Enter lab Exercise mark(14): ";
					cin >> markq2;
					push_quiz(:ass, markq2);
					cout << "Perncentage of Quiz is:" << percentageLabExercise(markq2) << "%" << endl;
				}

				else {
					cout << "Wrong option"
				}
			

			} while (true);

		else if (option1 == 3)
		{
		system("cls");
		cout << "Display menu \n";
		cout << "1. individual\n";
		cout << "2. All\n";
		cout << "3. Highest carry mark\n";
		cin >> option2;
			if(option2 == 1)
				system("cls");
				cout << "Enter student ID: " << endl;
				getline(cin, student_ID);
				list->record[list->index] = new pustStudent(student_ID, totalmark);

				cout << "Percentage of Quiz is:" << perncentageQuiz(markq) << "%" << endl;
				cout << "Percentage of Quiz is:" << percentageAssignment(markq) << "%" << endl;
				cout << "Percentage of Quiz is:" << percentageMidterm(markq) << "%" << endl;
				cout << "Percentage of Quiz is:" << percentageLabExercise(markq) << "%" << endl;
				cout << "Total carrymark is: " << totalMark << "%" << endl;

			}
			else if (option2 == 2) {

			}
			else if (option2 == 3) {
			cout << "Enter student ID: " << endl;
			getline(cin,student)
			}

		else if

		} while (option1 != 0);
		return 0;
	}
} 
Last edited on
> push_quiz(:ass, markq);
Just how much typing did you do before deciding to press "compile"?
You have the same mistake copy/pasted in multiple places - this is a bad way to code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 In function 'float carryMark()':
83:8: warning: unused variable 'cmark' [-Wunused-variable]
84:1: warning: no return statement in function returning non-void [-Wreturn-type]
 In function 'int main()':
128:16: error: expected primary-expression before ':' token
135:16: error: expected primary-expression before ':' token
142:16: error: expected primary-expression before ':' token
149:16: error: expected primary-expression before ':' token
164:8: error: expected 'while' before 'if'
164:8: error: expected '(' before 'if'
164:8: error: expected primary-expression before 'if'
164:8: error: expected ')' before 'if'
164:8: error: expected ';' before 'if'
168:36: error: expected type-specifier before 'pustStudent'
183:16: error: expected primary-expression before ':' token
191:16: error: expected primary-expression before ':' token
199:16: error: expected primary-expression before ':' token
207:16: error: expected primary-expression before ':' token
213:5: error: expected ';' before '}' token
218:3: error: expected '}' before 'else'
230:37: error: expected type-specifier before 'pustStudent'
236:39: error: 'totalMark' was not declared in this scope
244:16: error: 'student' was not declared in this scope
249:3: error: expected '(' before '}' token
252:1: error: expected 'while' before '}' token
252:1: error: expected '(' before '}' token
252:1: error: expected primary-expression before '}' token
252:1: error: expected ')' before '}' token
252:1: error: expected ';' before '}' token
88:11: warning: unused variable 'std' [-Wunused-variable]
89:14: warning: unused variable 'ass' [-Wunused-variable]
91:6: warning: unused variable 'i' [-Wunused-variable]
95:8: warning: unused variable 'totalmark' [-Wunused-variable]


Write 10 lines at a time, then compile.
Any errors you get are quick to locate and fix.


Not 200+ lines, and get pages of errors.
Apart from syntax issues, the first main issue is:

1
2
3
void push_quiz(Student** head_reference, float new_mark) {
....
push_quiz(&ass, markq);


where ass is of type Assessment*

push_quiz requires a pointer to pointer to Student, but you are passing a pointer to a pointer to Assessment........ ???
Topic archived. No new replies allowed.