how do i call cout statements to appear in a student report

I would like the results or output in void codesymbol and results in passfail to show in void print
******************************************************************
e.g
symbol code
A 7
B 6
c 5

outcome:passed
******************************************************************
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
  //program to compile a student academic report
#include<iostream>
#include<conio.h>
using namespace std;
void passorfail(float engMark1,float matMark1,float LOMark1,float HisMark1,float CLMark1,float GeoMark1,float i)
{   i =0;

    if (engMark1>=50)
    i++;
    if (matMark1>=50)
    i++;
    if (LOMark1>=50)
    i++;
    if (HisMark1>=50)
    i++;
    if (CLMark1>=50)
    i++;
    if (GeoMark1>=50)
    i++;

    if(engMark1>=50 && i>=4)
    cout<<"outcome : Passed";
    else
    cout<<"outcome:Fail";
}

void codeSymbol(float &engMark1,float matMark1,float LOMark1,float HisMark1,float CLMark1,float GeoMark1,float average1,char symbol)
{if (engMark1>=80 && engMark1<=100)
 cout<< "A\t\t7"<<endl;
    if (engMark1>=70 && engMark1<=79)
 cout<< "B\t\t6"<<endl;
 if (engMark1>=60 && engMark1<=69)
 cout<< "C\t\t5"<<endl;
    if (engMark1>=50 && engMark1<=59)
 cout<< "D\t\t4"<<endl;
 if (engMark1>=40 && engMark1<=49)
 cout<< "E\t\t3"<<endl;
    if (engMark1>=30 && engMark1<=39)
 cout<< "F\t\t2"<<endl;
 if (engMark1>=0 && engMark1<=29)
 cout<< "FF\t\t1"<<endl;

 if (matMark1>=80 && matMark1<=100)
 cout<< "A\t\t7"<<endl;
    if (matMark1>=70 && matMark1<=79)
 cout<< "B\t\t6"<<endl;
 if (matMark1>=60 && matMark1<=69)
 cout<< "C\t\t5"<<endl;
    if (matMark1>=50 && matMark1<=59)
 cout<< "D\t\t4"<<endl;
 if (matMark1>=40 && matMark1<=49)
 cout<< "E\t\t3"<<endl;
    if (matMark1>=70 && matMark1<=79)
 cout<< "F\t\t2"<<endl;
 if (matMark1>=80 && matMark1<=100)
 cout<< "FF\t\t1"<<endl;

    if (LOMark1>=80 && LOMark1<=100)
 cout<< "A\t\t7"<<endl;
 if (LOMark1>=70 && LOMark1<=79)
 cout<< "B\t\t6"<<endl;
    if (LOMark1>=60 && LOMark1<=69)
 cout<< "C\t\t5"<<endl;
 if (LOMark1>=50 && LOMark1<=59)
 cout<< "D\t\t4"<<endl;
    if (LOMark1>=40 && LOMark1<=49)
 cout<< "E\t\t3"<<endl;
if (LOMark1>=30 && LOMark1<=39)
 cout<< "F\t\t2"<<endl;
    if (LOMark1>=0 && LOMark1<=29)
 cout<< "FF\t\t1"<<endl;

 if(HisMark1>=80 && HisMark1<=100)
 cout<< "A\t\t7"<<endl;
    if (HisMark1>=70 && HisMark1<=79)
 cout<< "B\t\t6"<<endl;
 if (HisMark1>=60 && HisMark1<=69)
 cout<< "C\t\t5"<<endl;;
    if (HisMark1>=50 && HisMark1<=59)
 cout<< "D\t\t4"<<endl;;
 if (HisMark1>=40 && HisMark1<=49)
 cout<< "E\t\t3"<<endl;;
    if (HisMark1>=30 && HisMark1<=39)
 cout<< "F\t\t2"<<endl;;
 if (HisMark1>=0 && HisMark1<=29)
 cout<< "FF\t\t1"<<endl;

 if(CLMark1>=80 && CLMark1<=100)
 cout<< "A"<<endl;
    if (CLMark1>=70 && CLMark1<=79)
 cout<< "B"<<endl;
 if (CLMark1>=60 && engMark1<=69)
 cout<< "C"<<endl;;
    if (engMark1>=50 && CLMark1<=59)
 cout<< "D"<<endl;;
 if (CLMark1>=40 && CLMark1<=49)
 cout<< "E"<<endl;;
    if (CLMark1>=30 && CLMark1<=39)
 cout<< "F";;
 if (CLMark1>=0 && CLMark1<=29)
 cout<< "FF"<<endl;

 if(GeoMark1>=80 && GeoMark1<=100)
 cout<< "A"<<endl;
    if (GeoMark1>=70 && GeoMark1<=79)
 cout<< "B"<<endl;
 if (GeoMark1>=60 && GeoMark1<=69)
 cout<< "C"<<endl;;
    if (GeoMark1>=50 && GeoMark1<=59)
 cout<< "D"<<endl;;
 if (GeoMark1>=40 && GeoMark1<=49)
 cout<< "E"<<endl;;
    if (GeoMark1>=30 && GeoMark1<=39)
 cout<< "F"<<endl;;
 if (GeoMark1>=0 && GeoMark1<=29)
 cout<< "FF"<<endl;

  if(average1>=80 && average1<=100)
 cout<< "A"<<endl;
    if (average1>=70 && average1<=79)
 cout<< "B"<<endl;
 if (average1>=60 && average1<=69)
 cout<< "C"<<endl;;
    if (average1>=50 && average1<=59)
 cout<< "D"<<endl;;
 if (average1>=40 && average1<=49)
 cout<< "E"<<endl;;
    if (average1>=30 && average1<=39)
 cout<< "F"<<endl;;
 if (average1>=0 && average1<=29)
 cout<< "FF"<<endl;

 if (engMark1>=80 && engMark1<=100)
 cout<< "7"<<endl;
    if (engMark1>=70 && engMark1<=79)
 cout<< "6"<<endl;
 if (engMark1>=60 && engMark1<=69)
 cout<< "5"<<endl;;
    if (engMark1>=50 && engMark1<=59)
 cout<< "4"<<endl;;
 if (engMark1>=40 && engMark1<=49)
 cout<< "3"<<endl;;
    if (engMark1>=30 && engMark1<=39)
 cout<< "2"<<endl;;
 if (engMark1>=0 && engMark1<=29)
 cout<< "1";

 if (matMark1>=80 && matMark1<=100)
 cout<< "7";
    if (matMark1>=70 && matMark1<=79)
 cout<< "6";
 if (matMark1>=60 && matMark1<=69)
 cout<< "5";
    if (matMark1>=50 && matMark1<=59)
 cout<< "4";
 if (matMark1>=40 && matMark1<=49)
 cout<< "3";
    if (matMark1>=70 && matMark1<=79)
 cout<< "2";
 if (matMark1>=80 && matMark1<=100)
 cout<< "1";


    if (LOMark1>=80 && LOMark1<=100)
 cout<< "7";
 if (LOMark1>=70 && LOMark1<=79)
 cout<< "6";
    if (LOMark1>=60 && LOMark1<=69)
 cout<< "5";
 if (LOMark1>=50 && LOMark1<=59)
 cout<< "4";
    if (LOMark1>=40 && LOMark1<=49)
 cout<< "3";
if (LOMark1>=30 && LOMark1<=39)
 cout<< "2";
    if (LOMark1>=0 && LOMark1<=29)
 cout<< "1";

 if(HisMark1>=80 && HisMark1<=100)
 cout<< "7";
    if (HisMark1>=70 && HisMark1<=79)
 cout<< "6";
 if (HisMark1>=60 && HisMark1<=69)
 cout<< "5";;
    if (HisMark1>=50 && HisMark1<=59)
 cout<< "4";;
 if (HisMark1>=40 && HisMark1<=49)
 cout<< "3";;
    if (HisMark1>=30 && HisMark1<=39)
 cout<< "2";;
 if (HisMark1>=0 && HisMark1<=29)
 cout<< "1";

 if(CLMark1>=80 && CLMark1<=100)
 cout<< "7";
    if (CLMark1>=70 && CLMark1<=79)
 cout<< "6";
 if (CLMark1>=60 && engMark1<=69)
 cout<< "5";;
    if (engMark1>=50 && CLMark1<=59)
 cout<< "4";;
 if (CLMark1>=40 && CLMark1<=49)
 cout<< "3";;
    if (CLMark1>=30 && CLMark1<=39)
 cout<< "2";;
 if (CLMark1>=0 && CLMark1<=29)
 cout<< "1";

 if(GeoMark1>=80 && GeoMark1<=100)
 cout<< "7";
    if (GeoMark1>=70 && GeoMark1<=79)
 cout<< "6";
 if (GeoMark1>=60 && GeoMark1<=69)
 cout<< "5";;
    if (GeoMark1>=50 && GeoMark1<=59)
 cout<< "4";;
 if (GeoMark1>=40 && GeoMark1<=49)
 cout<< "3";;
    if (GeoMark1>=30 && GeoMark1<=39)
 cout<< "2";;
 if (GeoMark1>=0 && GeoMark1<=29)
 cout<< "1";

  if(average1>=80 && average1<=100)
 cout<< "7";
    if (average1>=70 && average1<=79)
 cout<< "6";
 if (average1>=60 && average1<=69)
 cout<< "5";;
    if (average1>=50 && average1<=59)
 cout<< "4";;
 if (average1>=40 && average1<=49)
 cout<< "3";;
    if (average1>=30 && average1<=39)
 cout<< "2";;
 if (average1>=0 && average1<=29)
 cout<< "1";




}





void print(string name ,string surname, string schoolname, float engMark1,float matMark1,float LOMark1,float HisMark1,float CLMark1,float GeoMark1,float average1,float highest,float lowest, char symbol, char code)
{
    cout<<"*************************************************************************"<<endl;
    cout<<"                               ****STUDENT ACADEMIC RECORD"<<endl;
    cout<<"This program inputs the learner marks of matric level"<<endl;
    cout<<"subjects and prints the student final report."<<endl;
    cout<<"***************************************************************************"<<endl;
    cout<<"*****"<<endl;
cout<<endl;
    cout<<"Name:"<<name<<surname;                    cout<<"\t\t\tSchool :"<<schoolname<<schoolname<<endl;
    cout<<endl;
    cout<<endl;
    cout<<"Subject";            cout<<"\t\t\tMark";             cout<<"\t\tSymbol" ;      cout<<"\tCode"<< endl;
    cout<<"English";            cout<<"\t\t\t"<<engMark1<<"%";       cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
    cout<<"Mathematics";        cout<<"\t\t"<<matMark1<<"%";     cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
    cout<<"Life Orientaton";    cout<<"\t\t"<<LOMark1<<"%";        cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
    cout<<"History";            cout<<"\t\t\t"<<HisMark1<<"%";       cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
    cout<<"Computer Literacy";  cout<<"\t"<<CLMark1<<"%";        cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
    cout<<"Geography";          cout<<"\t\t"<<GeoMark1<<"%";       cout<<"\t\t"<<symbol;     cout<<"\t"<<code<<endl;
cout<<endl;
    cout<<"Average Year Mark : "<<average1<< "\twith Symbol"<<symbol<<" \tand code :"<<code<<endl;
    cout<<endl;

cout<<"the highest mark was:"<<highest<<endl;
cout<<"the lowest mark was:"<<lowest<<endl;

cout<<"*************************************************************************"<<endl;

}
Last edited on
Hello RahRah,

A few things I see right off.

"conio.h" is not a standard C++ header file and not everyone has this header file with their compiler. I have not seen where in you code that you would need this header file, but you are missing "main".

"double"s are the preferred floating point number type. It is more accurate than a "float".

Watch your indenting. I first see it in lines 21 -24. Then in the "codeSymbol" function the "cout" statements need better indenting and I would say that every other "if "statement needs unindented.

I try to run your program to see how it works, but with out 'main" it may take awhile.

Hope that helps,

Andy
Hello RahRah,

I have fixed something up to see how the functions work. I do not know if the numbers I used are correct, but it works,

For these variables:
1
2
3
4
5
6
7
8
9
engMark1
matMark1
LOMark1
HisMark1
CLMark1
GeoMark1
i
average1
char symbol

If you could provide what value each variable would be it would help.

I also found in the "codeSymbol" function in the matMark1 section your last if statement reads
if (matMark1 >= 80 && matMark1 <= 100) I think you meant it to be
if (matMark1 >= 0 && matMark1 <= 29)

The output I get is:

outcome : Passed

A               7
A               7
FF              1
B               6
A               7
B
A
FF
7
716767


The first line may be better at the bottom, but works for testing. The "FF" should go away when the line(s) are fixed.

It also looks like there is duplication of a few sections in the "code

Andy

Edit: Sorry I meant to post this earlier and got tied up with the program.
Last edited on
Hello RahRah,

After working with the program and rereading your question I believe the answer to your question is.

First I created an overloaded function std::string codeSymbol(double course), but I am now thinking that it should take two parameters. Still working on the second parameter.

Then to use it:
std::cout << "English"; std::cout << "\t\t\t" << engMark1 << "%"; std::cout << "\t\t" << codeSymbol(engMark1); std::cout << "\t" << code << std::endl;
Notice the function call to codeSymbol(engMark1). The return value will be output in the "cout" statement.

I have only set this up for one subject and need to deal with the others.

Hope this helps,

Andy
@RahRah,
Whenever you find yourself doing essentially the same thing six times, it's time to write some smaller functions.
Whenever you find yourself doing exactly the same thing several times, it's time to delete some lines of code.
Hello RahRah,

This is the output I have achieved here with what I had to start with. All the numbers and letters come from the program except "Z" for code. I do not know what that is for,so I just hard coded that for now.

Not knowing what you did for input makes it hard to guess what to do.


outcome : Passed

*************************************************************************
                    **** STUDENT ACADEMIC RECORD ****

This program inputs the learner marks of matric level
subjects and prints the student final report.

*************************************************************************

Name: John Doe                  School: CSCC


Subject                 Mark            Symbol  Code
----------------------------------------------------
English                 80%               A      Z
Mathematics             85%               A      Z
Life Orientaton         75%               B      Z
History                 95%               A      Z
Computer Literacy       79%               B      Z
Geography               84%               A      Z

Average Year Mark: 83   with Symbol: A  and code: Z

the highest mark was: 95
the lowest  mark was: 75

*************************************************************************

 Press Enter to continue


If you look closely at the way every thing is spaced out it is because I changed the way things are output.

I do have a suggestion for your code in the "print" function:
1
2
3
4
5
6
7
8
9
10
std::cout << std::setw(24) << "English";
std::cout  << engMark1 << "%";
std::cout << std::setw(15) << ' ' << codeSymbol(eng, engMark1);
std::cout << std::setw(6) << ' ' << code << std::endl;
	
std::cout << std::setw(24) << "Mathematics"
	<< matMark1 << "%"
	<< std::setw(15) << ' '  // <--- Just prints blank spaces. The same thing happens on the laset line.
	<< codeSymbol(math, matMark1)
	<< std::setw(6) << ' ' << code << std::endl;

The first four lines show what you did in a more easy to read way. The second four lines demonstrate how you can chain all the separate "cout" statements into one single "cout" statement.

Hope that helps,

Andy
Goodmorning Andy

Thank you so much for the help. but i dont understand what oveloading a function means

First I created an overloaded function std::string codeSymbol(double course)

we just covered the topic on functions but that was never covered how do i go about it
i have done some of things you suggested but i am coming across two errors
error too few arguments to function 'void codesymbol
and error at this point in file


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
void codeSymbol(double engMark1,double matMark1,double LOMark1,double HisMark1,double CLMark1,double GeoMark1,double average1)
{if (engMark1>=80 && engMark1<=100)
    cout<< "A\t\t7"<<endl;
if (engMark1>=70 && engMark1<=79)
    cout<< "B\t\t6"<<endl;
if (engMark1>=60 && engMark1<=69)
    cout<< "C\t\t5"<<endl;
if (engMark1>=50 && engMark1<=59)
    cout<< "D\t\t4"<<endl;
if (engMark1>=40 && engMark1<=49)
    cout<< "E\t\t3"<<endl;
if (engMark1>=30 && engMark1<=39)
    cout<< "F\t\t2"<<endl;
if (engMark1>=0 && engMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (matMark1>=80 && matMark1<=100)
    cout<< "A\t\t7"<<endl;
if (matMark1>=70 && matMark1<=79)
    cout<< "B\t\t6"<<endl;
if (matMark1>=60 && matMark1<=69)
    cout<< "C\t\t5"<<endl;
if (matMark1>=50 && matMark1<=59)
    cout<< "D\t\t4"<<endl;
if (matMark1>=40 && matMark1<=49)
    cout<< "E\t\t3"<<endl;
if (matMark1>=70 && matMark1<=79)
    cout<< "F\t\t2"<<endl;
if (matMark1>=0 && matMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (LOMark1>=80 && LOMark1<=100)
    cout<< "A\t\t7"<<endl;
if (LOMark1>=70 && LOMark1<=79)
    cout<< "B\t\t6"<<endl;
if (LOMark1>=60 && LOMark1<=69)
    cout<< "C\t\t5"<<endl;
if (LOMark1>=50 && LOMark1<=59)
    cout<< "D\t\t4"<<endl;
if (LOMark1>=40 && LOMark1<=49)
    cout<< "E\t\t3"<<endl;
if (LOMark1>=30 && LOMark1<=39)
    cout<< "F\t\t2"<<endl;
if (LOMark1>=0 && LOMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(HisMark1>=80 && HisMark1<=100)
    cout<< "A\t\t7"<<endl;
if (HisMark1>=70 && HisMark1<=79)
    cout<< "B\t\t6"<<endl;
if (HisMark1>=60 && HisMark1<=69)
    cout<< "C\t\t5"<<endl;
if (HisMark1>=50 && HisMark1<=59)
    cout<< "D\t\t4"<<endl;
if (HisMark1>=40 && HisMark1<=49)
    cout<< "E\t\t3"<<endl;
if (HisMark1>=30 && HisMark1<=39)
    cout<< "F\t\t2"<<endl;
if (HisMark1>=0 && HisMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(CLMark1>=80 && CLMark1<=100)
    cout<< "A\t\t7"<<endl;
if (CLMark1>=70 && CLMark1<=79)
    cout<< "B\t\t6"<<endl;
if (CLMark1>=60 && engMark1<=69)
    cout<< "C\t\t5"<<endl;
if (CLMark1>=50 && CLMark1<=59)
    cout<< "D\t\t4"<<endl;
if (CLMark1>=40 && CLMark1<=49)
    cout<< "E\t\t3"<<endl;
if (CLMark1>=30 && CLMark1<=39)
    cout<< "F\t\t2";;
if (CLMark1>=0 && CLMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(GeoMark1>=80 && GeoMark1<=100)
    cout<< "A\t\t7"<<endl;
if (GeoMark1>=70 && GeoMark1<=79)
    cout<< "B\t\t6"<<endl;
if (GeoMark1>=60 && GeoMark1<=69)
    cout<< "C\t\t5"<<endl;
if (GeoMark1>=50 && GeoMark1<=59)
    cout<< "D\t\t4"<<endl;
if (GeoMark1>=40 && GeoMark1<=49)
    cout<< "E\t\t3"<<endl;
if (GeoMark1>=30 && GeoMark1<=39)
    cout<< "F\t\t2"<<endl;
if (GeoMark1>=0 && GeoMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(average1>=80 && average1<=100)
    cout<< "A\t\t7"<<endl;
if (average1>=70 && average1<=79)
    cout<< "B\t\t6"<<endl;
if (average1>=60 && average1<=69)
    cout<< "C\t\t5"<<endl;
if (average1>=50 && average1<=59)
    cout<< "D\t\t4"<<endl;
if (average1>=40 && average1<=49)
    cout<< "E\t\t3"<<endl;
if (average1>=30 && average1<=39)
    cout<< "F\t\t2"<<endl;
if (average1>=0 && average1<=29)
    cout<< "FF\t\t1"<<endl;
}



void print(string name ,string surname, string schoolname, double engMark1,double matMark1,double LOMark1,double HisMark1,double CLMark1,double GeoMark1,double average1,double highest,double lowest, char symbol, char code,double eng,double mat,double LO,double His,double CL,double Geo,double ave1)

{
    cout<<"*************************************************************************"<<endl;
    cout<<"                               ****STUDENT ACADEMIC RECORD"<<endl;
    cout<<"This program inputs the learner marks of matric level"<<endl;
    cout<<"subjects and prints the student final report."<<endl;
    cout<<"***************************************************************************"<<endl;
    cout<<"*****"<<endl;
cout<<endl;
    cout<<"Name:"<<name<<surname;                    cout<<"\t\t\tSchool :"<<schoolname<<endl;
    cout<<endl;
    cout<<endl;
    cout<<"Subject";            cout<<"\t\t\tMark";             cout<<"\t\tSymbol" ;      cout<<"\tCode"<< endl;
    cout<<"English";            cout<<"\t\t\t"<<engMark1<<"%"<<"\t\t"<<codeSymbol(engMark1);
    cout<<"Mathematics";        cout<<"\t\t"<<matMark1<<"%"<<"\t\t"<<codeSymbol(matMark1);
    cout<<"Life Orientaton";    cout<<"\t\t"<<LOMark1<<"%"<<"\t\t"<<codeSymbol(LOMark1);
    cout<<"History";            cout<<"\t\t\t"<<HisMark1"%"<<"\t\t"<<codeSymbol(HisMark1);
    cout<<"Computer Literacy";  cout<<"\t"<<CLMark1<<"%"<<"\t\t"<<codeSymbol(CLMark1);
    cout<<"Geography";          cout<<"\t\t"<<GeoMark1<<"%"<<"\t\t"<<codeSymbol(GeoMark1);
cout<<endl;
    cout<<"Average Year Mark : "<<average1<<"%" "\twith Symbol"<<codeSymbol(average1)<< endl;
    cout<<endl;

cout<<"the highest mark was:"<<highest<<"%"<<endl;
cout<<"the lowest mark was:"<<lowest<<"%"<<endl;

cout<<"*************************************************************************"<<endl;

}



int main()

{
    string name1,surname1,schoolname1,avgmark;
    double engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,i,mark;
    char symbol1, code1;


    studentDetails(name1,surname1,schoolname1);
    cout<<endl;
getMarks(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
average=averageyearmark(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
minMax(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,highest1,lowest1);

cout<<endl;
awardDistinction(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average);
cout<<endl;
cout<<endl;
print(name1,surname1,schoolname1, engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,symbol1, code1,mark);
passorfail(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,i);
cout<<endl;
codeSymbol(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average);

    return 0;
}
Last edited on
Hello RahRah,

Sorry while working on this reply my computer locked up and I lost everything,so I will try again.

An overloaded function is based on using an already used function name ,but with different parameters. The return type can be the same or different. It is the parameters that make an overloaded function not the return type.

An example of what I did. Your original function call:
void codeSymbol(double &course, double matMark1, double LOMark1, double HisMark1, double CLMark1, double GeoMark1, double average1, char symbol)
The overloaded function call:
std::string codeSymbol(courses name, double course)

The overloaded function looks like this:
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
std::string codeSymbol(courses name, double course)
{
	char symbol{};

	switch (name)
	{
		case eng:
			return ReturnScore(course);
			break;
		case math:
			return ReturnScore(course);
			break;
		case Life:
			return ReturnScore(course);
		case His:
			return ReturnScore(course);
		case computer:
			return ReturnScore(course);
		case geography:
			return ReturnScore(course);
		case avg:
			return ReturnScore(course);
		default:
			break;
	}
}

And the "ReturnScore" function looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
std::string ReturnScore(double score)
{
	if (score >= 80 && score <= 100)
		return "A";
	if (score >= 70 && score <= 79)
		return "B";
	if (score >= 60 && score <= 69)
		return "C";
	if (score >= 50 && score <= 59)
		return "D";
	if (score >= 40 && score <= 49)
		return "E";
	if (score >= 70 && score <= 79)
		return "F";
	if (score >= 0 && score <= 29)
		return "FF";
}

Looking at these functions today I am starting to think I could combine the two and do away with the "switch" and most likely the first parameter and accomplish the same thing. I will have to look into that. Fo now it at least gives you an idea of what you could do.

The error message is related to line 124 of the "print" function. You have:
cout<<"English"; cout<<"\t\t\t"<<engMark1<<"%"<<"\t\t"<<codeSymbol(engMark1);
and it should be:
cout<<"English"; cout<<"\t\t\t"<<engMark1<<"%"<<"\t\t"<<codeSymbol(eng, engMark1);

The function requires two parameters and you are only sending it one. Hence the error message "too few arguments to function call".

The first parameter is based on this "enum" I put at the top of the file. const enum courses { eng = 1, math, Life, His, computer, geography, avg };. The names can be changed, spelled out if you will, but I would stay with something that is meaningful for what it is. Since an "enum will start at zero with its numbering and add one for each entry I chose to start the first name at 1. It is not necessary, that is where my head was at when I wrote it, also in the "switch" making the first case 1 be a little easier to understand than zero.

For what its worth I set up the "print" function this way:
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
void Print(std::string name, std::string surname, std::string schoolname, double engMark1, double matMark1, double LOMark1, double HisMark1, double CLMark1, double GeoMark1, double average1, double highest, double lowest, char symbol, char code)
{
	std::cout << "*************************************************************************" << std::endl;
	std::cout << std::setw(20) << ' ' << "**** STUDENT ACADEMIC RECORD ****\n" << std::endl;
	std::cout << "This program inputs the learner marks of matric level" << std::endl;
	std::cout << "subjects and prints the student final report.\n" << std::endl;
	std::cout << "*************************************************************************" << std::endl;
	//std::cout << "*****" << std::endl;
	std::cout << std::endl;

	std::cout << "Name: " << name << ' ' << surname;
	std::cout << "\t\t\tSchool: " << schoolname << std::endl;
	std::cout << std::endl;
	std::cout << std::endl;
	std::cout << "Subject";
	std::cout << "\t\t\tMark"; 
	std::cout << "\t\tSymbol"; 
	std::cout << "\tCode" << std::endl;

	std::cout << std::setfill('-') << std::setw(52) << '-' << std::setfill(' ') << std::endl;
	
	std::cout << std::left;

	std::cout << std::setw(24) << "English";
	std::cout  << engMark1 << "%";
	std::cout << std::setw(15) << ' ' << codeSymbol(eng, engMark1);
	std::cout << std::setw(6) << ' ' << code << std::endl;
	
	std::cout << std::setw(24) << "Mathematics"
		<< matMark1 << "%"
		<< std::setw(15) << ' '  // <--- Just prints blank spaces. The same thing happens on the laset line.
		<< codeSymbol(math, matMark1)
		<< std::setw(6) << ' ' << code << std::endl;

	std::cout << std::setw(24) << "Life Orientaton";
	std::cout << LOMark1 << "%";
	std::cout << std::setw(15) << ' ' << codeSymbol(Life, LOMark1);
	std::cout << std::setw(6) << ' ' << code << std::endl;

	std::cout << std::setw(24) << "History";
	std::cout << HisMark1 << "%";
	std::cout << std::setw(15) << ' ' << codeSymbol(His, HisMark1);
	std::cout << std::setw(6) << ' ' << code << std::endl;

	std::cout << std::setw(24) << "Computer Literacy";
	std::cout << CLMark1 << "%";
	std::cout << std::setw(15) << ' ' << codeSymbol(computer, CLMark1);
	std::cout << std::setw(6) << ' ' << code << std::endl;

	std::cout << std::setw(24) << "Geography";
	std::cout << GeoMark1 << "%";
	std::cout << std::setw(15) << ' ' << codeSymbol(geography, GeoMark1);
	std::cout << std::setw(6) << ' ' << code << std::endl;

	std::cout << std::endl;

	std::cout << "Average Year Mark: " << average1 << "\twith Symbol: " << codeSymbol(avg, average1) << " \tand code: " << code << std::endl;

	std::cout << std::endl;

	std::cout << std::setw(22) << "the highest mark was: " << highest << std::endl;
	std::cout << std::setw(22) << "the lowest  mark was: " << lowest << '\n' << std::endl;

	std::cout << "*************************************************************************" << std::endl;
}

Lines 24 - 27 show you how you can take what you had and make it more readable.

Lines 29 - 33 Show you how you can chain everything together and even separate the code on different lines, but it is still considered a whole because the compiler does not care about white space.

Line 20. will print a line of "-" across the screen. And line 22 tells the "cout" to print what is in a given space to the "left" side of the space. Something worth learning, but you can do with out it right now.

Any thing else you do not understand let me know.

Hope that helps,

Andy
Thank you Andy let me do what you have suggested and get back to you if i face problems thank you so much once again
Goodafternoon Handy

I have tried what you said i should do but i am getting this error message. I am still yet to input your suggestion on how the report should look

error: no matching function for call to 'codeSymbol(double&, double&)'|

error: call of overloaded 'codeSymbol(double&, double&, double&, double&, double&, double&, double&, double&)' is ambiguous|


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
void print(string name ,string surname, string schoolname ,double engMark1,double matMark1,double LOMark1,double HisMark1,double CLMark1,double GeoMark1,double average1,double highest,double lowest, double eng,double math,double Life,double His,double comp,double geo,double avg,double course)
{
    cout<<"*************************************************************************"<<endl;
    cout<<"                               ****STUDENT ACADEMIC RECORD"<<endl;
    cout<<"This program inputs the learner marks of matric level"<<endl;
    cout<<"subjects and prints the student final report."<<endl;
    cout<<"***************************************************************************"<<endl;
    cout<<"*****"<<endl;
cout<<endl;
    cout<<"Name:"<<name<<surname;                    cout<<"\t\t\tSchool :"<<schoolname<<schoolname<<endl;
    cout<<endl;
    cout<<endl;
    cout<<"Subject";            cout<<"\t\t\tMark";             cout<<"\t\tSymbol" ;      cout<<"\tCode"<< endl;
    cout<<"English";            cout<<"\t\t\t"<<engMark1<<"%";       cout<<"\t\t"<<codeSymbol(eng,engMark1)<<endl;
    cout<<"Mathematics";        cout<<"\t\t"<<matMark1<<"%";     cout<<"\t\t"<<codeSymbol(math,matMark1)<<    endl;
    cout<<"Life Orientaton";    cout<<"\t\t"<<LOMark1<<"%";        cout<<"\t\t"<<codeSymbol(Life,LOMark1)<<    endl;
    cout<<"History";            cout<<"\t\t\t"<<HisMark1<<"%";       cout<<"\t\t"<<codeSymbol(His,HisMark1)<<     endl;
    cout<<"Computer Literacy";  cout<<"\t"<<CLMark1<<"%";        cout<<"\t\t"<<codeSymbol(comp,CLMark1)<<  endl;
    cout<<"Geography";          cout<<"\t\t"<<GeoMark1<<"%";       cout<<"\t\t"<<codeSymbol(geo,GeoMark1)<<    endl;
cout<<endl;
    cout<<"Average Year Mark : "<<average1<<"%" "\twith Symbol"<<codeSymbol(avg,average1)<<endl;
    cout<<endl;

cout<<"the highest mark was:"<<highest<<"%"<<endl;
cout<<"the lowest mark was:"<<lowest<<"%"<<endl;

cout<<"*************************************************************************"<<endl;

}


int main()

{
    string name1,surname1,schoolname1;
    double engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,i, course,eng1, math1,Life1,His1,comp1,geo1,avg1;



    studentDetails(name1,surname1,schoolname1);
    cout<<endl;
    getMarks(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
    average=averageyearmark(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
    minMax(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,highest1,lowest1);

    cout<<endl;
    awardDistinction(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average);
    cout<<endl;
    cout<<endl;
    print(name1,surname1,schoolname1, engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,course,eng1,math1,Life1,His1,comp1,geo1,avg1);
    passorfail(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,i);
    cout<<endl;
    cout<<endl;
    codeSymbol(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,course);
    codeSymbol(course,eng1,math1,Life1,His1,comp1,geo1,avg1);
    return 0;
}

}
Last edited on
Hello RahRah,

According to your error message
error: no matching function for call to 'codeSymbol(float&, float&)'|
It looks like the overloaded function iscodeSymbol(float&, float&). That is not what I showed you earlier.

You may think that the problem lies in the "print' function, but it is in the "codeSymbol" function that takes two parameters. Neither of which should be a "float".

Show me the function "codeSymbol(parm1, parm2)" so I can see what you did.

Just because the error message may point to a line in the "print" function does not mean that is where the error is or starts.

Most times it is better to post the complete error message and not the part that you think is important. There is more useful information in the error message than you think.

I realize that I am showing you concepts that you are not familiar with and someday will cover, but for now I think the problem is that we are about one page different in the same book. I need to get us on the same page at the same time.

I also think it is a good time to post your whole code so I can see where you are at and can better address any problems.

Hope that helps,

Andy
Goodafternoon Andy

yes i m new to programming and some topics havent been covered.I spent the day trying to understnd switch statements and how they operate.


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
void codeSymbol(double engMark1,double matMark1,double LOMark1,double HisMark1,double CLMark1,double GeoMark1,double average1,double &course)
{
if(engMark1>=80 && engMark1<=100)
    cout<< "A\t\t7"<<endl;
if (engMark1>=70 && engMark1<=79)
    cout<< "B\t\t6"<<endl;
if (engMark1>=60 && engMark1<=69)
    cout<< "C\t\t5"<<endl;
if (engMark1>=50 && engMark1<=59)
    cout<< "D\t\t4"<<endl;
if (engMark1>=40 && engMark1<=49)
    cout<< "E\t\t3"<<endl;
if (engMark1>=30 && engMark1<=39)
    cout<< "F\t\t2"<<endl;
if (engMark1>=0 && engMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (matMark1>=80 && matMark1<=100)
    cout<< "A\t\t7"<<endl;
if (matMark1>=70 && matMark1<=79)
    cout<< "B\t\t6"<<endl;
if (matMark1>=60 && matMark1<=69)
    cout<< "C\t\t5"<<endl;
if (matMark1>=50 && matMark1<=59)
    cout<< "D\t\t4"<<endl;
if (matMark1>=40 && matMark1<=49)
    cout<< "E\t\t3"<<endl;
if (matMark1>=70 && matMark1<=79)
    cout<< "F\t\t2"<<endl;
if (matMark1>=0 && matMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (LOMark1>=80 && LOMark1<=100)
    cout<< "A\t\t7"<<endl;
if (LOMark1>=70 && LOMark1<=79)
    cout<< "B\t\t6"<<endl;
if (LOMark1>=60 && LOMark1<=69)
    cout<< "C\t\t5"<<endl;
if (LOMark1>=50 && LOMark1<=59)
    cout<< "D\t\t4"<<endl;
if (LOMark1>=40 && LOMark1<=49)
    cout<< "E\t\t3"<<endl;
if (LOMark1>=30 && LOMark1<=39)
    cout<< "F\t\t2"<<endl;
if (LOMark1>=0 && LOMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (HisMark1>=80 && HisMark1<=100)
    cout<< "A\t\t7"<<endl;
if (HisMark1>=70 && HisMark1<=79)
    cout<< "B\t\t6"<<endl;
if (HisMark1>=60 && HisMark1<=69)
    cout<< "C\t\t5"<<endl;
if (HisMark1>=50 && HisMark1<=59)
    cout<< "D\t\t4"<<endl;
if (HisMark1>=40 && HisMark1<=49)
    cout<< "E\t\t3"<<endl;
if (HisMark1>=30 && HisMark1<=39)
    cout<< "F\t\t2"<<endl;
if (HisMark1>=0 && HisMark1<=29)
    cout<< "FF\t\t1"<<endl;

if (CLMark1>=80 && CLMark1<=100)
    cout<< "A\t\t7"<<endl;
if (CLMark1>=70 && CLMark1<=79)
    cout<< "B\t\t6"<<endl;
if (CLMark1>=60 && engMark1<=69)
    cout<< "C\t\t5"<<endl;
if (CLMark1>=50 && CLMark1<=59)
    cout<< "D\t\t4"<<endl;
if (CLMark1>=40 && CLMark1<=49)
    cout<< "E\t\t3"<<endl;
if (CLMark1>=30 && CLMark1<=39)
    cout<< "F\t\t2";;
if (CLMark1>=0 && CLMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(GeoMark1>=80 && GeoMark1<=100)
    cout<< "A\t\t7"<<endl;
if (GeoMark1>=70 && GeoMark1<=79)
    cout<< "B\t\t6"<<endl;
if (GeoMark1>=60 && GeoMark1<=69)
    cout<< "C\t\t5"<<endl;
if (GeoMark1>=50 && GeoMark1<=59)
    cout<< "D\t\t4"<<endl;
if (GeoMark1>=40 && GeoMark1<=49)
    cout<< "E\t\t3"<<endl;
if (GeoMark1>=30 && GeoMark1<=39)
    cout<< "F\t\t2"<<endl;
if (GeoMark1>=0 && GeoMark1<=29)
    cout<< "FF\t\t1"<<endl;

if(average1>=80 && average1<=100)
    cout<< "A\t\t7"<<endl;
if (average1>=70 && average1<=79)
    cout<< "B\t\t6"<<endl;
if (average1>=60 && average1<=69)
    cout<< "C\t\t5"<<endl;
if (average1>=50 && average1<=59)
    cout<< "D\t\t4"<<endl;
if (average1>=40 && average1<=49)
    cout<< "E\t\t3"<<endl;
if (average1>=30 && average1<=39)
    cout<< "F\t\t2"<<endl;
if (average1>=0 && average1<=29)
    cout<< "FF\t\t1"<<endl;



}

std::string ReturnScore(double score)
{
	if (score >= 80 && score <= 100)
		return "A";
	if (score >= 70 && score <= 79)
		return "B";
	if (score >= 60 && score <= 69)
		return "C";
	if (score >= 50 && score <= 59)
		return "D";
	if (score >= 40 && score <= 49)
		return "E";
	if (score >= 70 && score <= 79)
		return "F";
	if (score >= 0 && score <= 29)
		return "FF";
}

std::string codeSymbol( string coursename, double course,float eng,float math,float Life,float His,float comp,float geo,float avg)
{
	char symbol{};

	switch (coursename)
	{
		case eng:
			return ReturnScore(course);
			break;
		case math:
			return ReturnScore(course);
			break;
		case Life:
			return ReturnScore(course);
		case His:
			return ReturnScore(course);
		case comp:
			return ReturnScore(course);
		case geo:
			return ReturnScore(course);
		case avg:
			return ReturnScore(course);
		default:
			break;
	}

}

void print(string name ,string surname, string schoolname ,double engMark1,double matMark1,double LOMark1,double HisMark1,double CLMark1,double GeoMark1,double average1,double highest,double lowest, float eng,float math,float Life,float His,float comp,float geo,float avg,float course)
{
    cout<<"*************************************************************************"<<endl;
    cout<<"                               ****STUDENT ACADEMIC RECORD"<<endl;
    cout<<"This program inputs the learner marks of matric level"<<endl;
    cout<<"subjects and prints the student final report."<<endl;
    cout<<"***************************************************************************"<<endl;
    cout<<"*****"<<endl;
cout<<endl;
    cout<<"Name:"<<name<<surname;                    cout<<"\t\t\tSchool :"<<schoolname<<schoolname<<endl;
    cout<<endl;
    cout<<endl;
    cout<<"Subject";            cout<<"\t\t\tMark";             cout<<"\t\tSymbol" ;      cout<<"\tCode"<< endl;
    cout<<"English";            cout<<"\t\t\t"<<engMark1<<"%";       cout<<"\t\t"<<codeSymbol(eng,engMark1)<<endl;
    cout<<"Mathematics";        cout<<"\t\t"<<matMark1<<"%";     cout<<"\t\t"<<codeSymbol(math,matMark1)<<    endl;
    cout<<"Life Orientaton";    cout<<"\t\t"<<LOMark1<<"%";        cout<<"\t\t"<<codeSymbol(Life,LOMark1)<<    endl;
    cout<<"History";            cout<<"\t\t\t"<<HisMark1<<"%";       cout<<"\t\t"<<codeSymbol(His,HisMark1)<<     endl;
    cout<<"Computer Literacy";  cout<<"\t"<<CLMark1<<"%";        cout<<"\t\t"<<codeSymbol(comp,CLMark1)<<  endl;
    cout<<"Geography";          cout<<"\t\t"<<GeoMark1<<"%";       cout<<"\t\t"<<codeSymbol(geo,GeoMark1)<<    endl;
cout<<endl;
    cout<<"Average Year Mark : "<<average1<<"%" "\twith Symbol"<<codeSymbol(avg,average1)<<endl;
    cout<<endl;

cout<<"the highest mark was:"<<highest<<"%"<<endl;
cout<<"the lowest mark was:"<<lowest<<"%"<<endl;

cout<<"*************************************************************************"<<endl;

}


int main()

{
    string name1,surname1,schoolname1;
    double engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,i;
    float course,eng1, math1,Life1,His1,comp1,geo1,avg1;



    studentDetails(name1,surname1,schoolname1);
    cout<<endl;
    getMarks(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
    average=averageyearmark(engMark,matMark,LOMark,HisMark,CLMark,GeoMark);

    cout<<endl;
    minMax(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,highest1,lowest1);

    cout<<endl;
    awardDistinction(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average);
    cout<<endl;
    cout<<endl;
    print(name1,surname1,schoolname1, engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,highest1,lowest1,course,eng1,math1,Life1,His1,comp1,geo1,avg1);
    passorfail(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,i);
    cout<<endl;
    cout<<endl;
    codeSymbol(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,course);
    codeSymbol(course,eng1,math1,Life1,His1,comp1,geo1,avg1);
    return 0;
}
Hello RahRah,

When I said the whole program I meant from the first "#include" to the last closing } of the file or the "whole file". "main" is calling functions that are not there.

Another thing I notices is that in the first program you called the variable "engMark1", but in the last post you called the variable "engMark". I would prefer the second variable name because the "1" is not really needed. My point is that you should be consistent between the first attempt and a revision.

At the beginning of "main" you are calling functions that there is no code for. With out them I can not tell if they are right or wrong.

At the end of "main" you call the function codeSymbol(engMark,matMark,LOMark,HisMark,CLMark,GeoMark,average,course); the way it should be. the next line calls the overloaded function codeSymbol(course,eng1,math1,Life1,His1,comp1,geo1,avg1);,but you are using the wrong set of parameters for this function and it is not meant to be called from "main".

When I run the program I get:






*************************************************************************
                               ****STUDENT ACADEMIC RECORD
This program inputs the learner marks of matric level
subjects and prints the student final report.
***************************************************************************
*****

Name:JohnDoe                    School :CSCCCSCC


Subject                 Mark            Symbol  Code
English                 80%             A        Z
Mathematics             85%             A        Z
Life Orientaton         75%             B       Z
History                 95%             A
Computer Literacy       79%             B
Geography               84%             A

Average Year Mark : 83% with SymbolA

the highest mark was:95%
the lowest mark was:75%
*************************************************************************


A               7
A               7
B               6
A               7
B               6
A               7
A               7


 Press Enter to continue


I see that the extra blank lines come from "main". For now I put a comments on those blank lines.

End of part 1.
Part 2.

Here is what I did with your program with what I had to work with:
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
// This is from your latest version.

#include <iostream>
#include <iomanip>
#include <string>
#include <limits>

// --- Add any header files you create.

// <--- Constant global variables.
const enum courses { eng = 1, math, Life, His, computer, geography, avg };


std::string ReturnScore(double score)
{
	if (score >= 80 && score <= 100)
		return "A";
	if (score >= 70 && score <= 79)
		return "B";
	if (score >= 60 && score <= 69)
		return "C";
	if (score >= 50 && score <= 59)
		return "D";
	if (score >= 40 && score <= 49)
		return "E";
	if (score >= 70 && score <= 79)
		return "F";
	if (score >= 0 && score <= 29)
		return "FF";
}

std::string codeSymbol(courses coursename, double score)
{
	char symbol{};

	switch (scorename)
	{
	case eng:
		return ReturnScore(score);
		break;
	case math:
		return ReturnScore(score);
		break;
	case Life:
		return ReturnScore(score);
	case His:
		return ReturnScore(score);
	case computer:
		return ReturnScore(score);
	case geography:
		return ReturnScore(score);
	case avg:
		return ReturnScore(score);
	default:
		break;
	}

}

void print(std::string name, std::string surname, std::string schoolname, double engMark1, double matMark1, double LOMark1, double HisMark1, double CLMark1, double GeoMark1, double average1, double highest, double lowest, char code)
{
	std::cout << "*************************************************************************\n";
	std::cout << "                     **** STUDENT ACADEMIC RECORD ****\n" << std::endl;
	std::cout << "This program inputs the learner marks of matric level" << std::endl;
	std::cout << "subjects and prints the student final report." << std::endl;
	std::cout << "***************************************************************************" << std::endl;
	std::cout << "*****" << std::endl;
	std::cout << std::endl;
	std::cout << "Name:" << name << surname;                    std::cout << "\t\t\tSchool :" << schoolname << schoolname << std::endl;
	std::cout << std::endl;
	std::cout << std::endl;
	std::cout << "Subject";            std::cout << "\t\t\tMark";             std::cout << "\t\tSymbol";      std::cout << "\tCode" << std::endl;

	std::cout << "English";            std::cout << "\t\t\t" << engMark1 << "%";       std::cout << "\t\t" << codeSymbol(eng, engMark1) << std::setw(8) << ' ' << code << std::endl;

	std::cout << "Mathematics";        std::cout << "\t\t" << matMark1 << "%";     std::cout << "\t\t" << codeSymbol(math, matMark1) << std::setw(8) << ' ' << code << std::endl;

	std::cout << "Life Orientaton";    std::cout << "\t\t" << LOMark1 << "%";        std::cout << "\t\t" << codeSymbol(Life, LOMark1) << "\t" << code << std::endl;

	std::cout << "History";            std::cout << "\t\t\t" << HisMark1 << "%";       std::cout << "\t\t" << codeSymbol(His, HisMark1) << std::endl;

	std::cout << "Computer Literacy";  std::cout << "\t" << CLMark1 << "%";        std::cout << "\t\t" << codeSymbol(computer, CLMark1) << std::endl;  // <---Changed spelling of "comp".

	std::cout << "Geography";          std::cout << "\t\t" << GeoMark1 << "%";       std::cout << "\t\t" << codeSymbol(geography, GeoMark1) << std::endl;  // <---Changed spelling of "geo".
	std::cout << std::endl;

	std::cout << "Average Year Mark : " << average1 << "%" "\twith Symbol" << codeSymbol(avg, average1) << std::endl;
	std::cout << std::endl;

	std::cout << "the highest mark was:" << highest << "%" << std::endl;
	std::cout << "the lowest mark was:" << lowest << "%" << std::endl;

	std::cout << "*************************************************************************" << std::endl;

}

// <--- I had this code for min/max that I used in another function. Not sure what you did, so I came
// up with this. "highest" and "lowest" are pased by reference so their values will be changed back in
// "main". The other variables are made "const" so that their value can not be changed in the function.
// You may have done this differently. Without your function it is hard to see what you did.

void minMax(const double engMark1, const double matMark1, const double LOMark1, const double HisMark1, const double CLMark1, const double GeoMark1, double& highest, double& lowest)
{
	if (engMark1 < lowest)
		lowest = engMark1;
	if (matMark1 < lowest)
		lowest = matMark1;
	if (LOMark1 < lowest)
		lowest = LOMark1;
	if (HisMark1 < lowest)
		lowest = HisMark1;
	if (CLMark1 < lowest)
		lowest = CLMark1;
	if (GeoMark1 < lowest)
		lowest = GeoMark1;

	if (engMark1 > highest)
		highest = engMark1;
	if (matMark1 > highest)
		highest = matMark1;
	if (LOMark1 < highest)
		highest = LOMark1;
	if (HisMark1 > highest)
		highest = HisMark1;
	if (CLMark1 > highest)
		highest = CLMark1;
	if (GeoMark1 > highest)
		highest = GeoMark1;
}

int main()

{
	//std::string name1, surname1, schoolname1;
	//double engMark, matMark, LOMark, HisMark, CLMark, GeoMark, average, highest1, lowest1, i;
	//float xz, eng1, math1, Life1, His1, comp1, geo1, avg1;
	double engMark{ 80 };
	double matMark{ 85 };
	double LOMark{ 75 };
	double HisMark{ 95 };
	double CLMark{ 79 };
	double GeoMark{ 84 };
	double average{ 83 };
	double highest{};  // <--- Needs to be captured somewhere not hard coaded.
	double lowest{ 100 };  // <--- Needs to be captured somewhere not hard coaded.
	char symbol{};
	char code{ 'Z' };
	std::string name{ "John" };
	std::string surname{ "Doe" };
	std::string schoolname{ "CSCC" };

	//studentDetails(name1, surname1, schoolname1);
	//std::cout << std::endl;
	//getMarks(engMark, matMark, LOMark, HisMark, CLMark, GeoMark);

	//std::cout << std::endl;
	//average = averageyearmark(engMark, matMark, LOMark, HisMark, CLMark, GeoMark);

	//std::cout << std::endl;
	minMax(engMark, matMark, LOMark, HisMark, CLMark, GeoMark, highest, lowest);

	//std::cout << std::endl;
	//awardDistinction(engMark, matMark, LOMark, HisMark, CLMark, GeoMark, average);
	//std::cout << std::endl;
	std::cout << std::endl;
	print(name, surname, schoolname, engMark, matMark, LOMark, HisMark, CLMark, GeoMark, average, highest, lowest, code);
	//passorfail(engMark, matMark, LOMark, HisMark, CLMark, GeoMark, i);
	//std::cout << std::endl;
	//std::cout << std::endl;
	//codeSymbol(engMark, matMark, LOMark, HisMark, CLMark, GeoMark, average);  // <--- Changed. Removed the last  two parameter.
	//codeSymbol(course, eng1, math1, Life1, His1, comp1, geo1, avg1);  // <--- This line not needed here.

	// <--- Used mostly for testing in Debug mode. Removed if compiled for release.
	// <--- Used to keep the console window open in Visual Studio Debug mode.
	// The next line may not be needid. If you have to press enter to see the prompt it is not needed.
	//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  // <--- Requires header file <limits>.
	std::cout << "\n\n Press Enter to continue";
	std::cin.get();

	return 0;
}

And the output is:

*************************************************************************
                     **** STUDENT ACADEMIC RECORD ****

This program inputs the learner marks of matric level
subjects and prints the student final report.
***************************************************************************
*****

Name:JohnDoe                    School :CSCCCSCC


Subject                 Mark            Symbol  Code
English                 80%             A        Z
Mathematics             85%             A        Z
Life Orientaton         75%             B       Z
History                 95%             A
Computer Literacy       79%             B
Geography               84%             A

Average Year Mark : 83% with SymbolA

the highest mark was:95%
the lowest mark was:75%
*************************************************************************


 Press Enter to continue


End part 2
Part 3.

Looking at the above output the tab does not line things up very well. You might want to take the tabs out of "Symbol" and "code" and use spaces to center the headings. Then you can keep the tabs in the lines that follow.

I do not know what "Symbol" and "Code" are actually for and what should be in those columns. I may have it backwards for all I know. If "Code" should be something different for each subject I need to know what that would be to help you code for it.

In the first output block at the top of the page if the column of letters and the column of numbers need to be there it would help if I could understand what they are for.

I realize that some of my code is a bit beyond where you are at and I will help you understand what you do not know. If it turns out that you just can not use it let me know and we can find another way.

Hope that helps,

Andy
Topic archived. No new replies allowed.