Unable to Call Function

Pages: 123
Ok, I am looking.
okay i added a for loop in the lettercalc function and it outputs now i have an example of code that checks for the largest value in a number set i am not sure how to add an array with the final letter grades then compare. the largest function is meant to do that but getting the array in that function will be an issue. here is the updated copy

#include <iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;
struct student {
string SFname;
string SLname;
int Sid;
double sgrade[4];
double fgrade;
char lgrade;
};


//void output();
int largest(const int list[], int low, int high);
void input(student Students[], int &x);
void Calc(student Students[]);
void gradecalc(student Students[]);

int main()
{
double fgrade = 0.0;
int x = 0;
//double fgrade;
student Students[10];
input(Students, x);
Calc(Students);
gradecalc(Students);
cin.get(); cin.get();
return 0;
}
void input(student Students[], int &x){

for (int x = 0; x < 10; x++) {
cout << "Please enter Students first name" << endl;
cin >> Students[x].SFname;
cout << "Please enter Students last name" << endl;
cin >> Students[x].SLname;
cout << "Please enter the Students ID" << endl;
cin >> Students[x].Sid;
cout << "Please enter the students first grade" << endl;
cin >> Students[x].sgrade[0];
cout << "Please enter the students second grade" << endl;
cin >> Students[x].sgrade[1];
cout << "Please enter the students third grade" << endl;
cin >> Students[x].sgrade[2];
cout << "Please enter the students fourth grade" << endl;
cin >> Students[x].sgrade[3];

}

}
void Calc(student Students[]){

double grade=0.0;
double total;
total = 0;
for (int x = 0; x < 10; x++) {

total = Students[x].sgrade[0] + Students[x].sgrade[1] + Students[x].sgrade[2] + Students[x].sgrade[3];

Students[x].fgrade = total / 4;


}
return ;
}

int largest(const int list[], int low, int high) {
int max;
if (low == high)
return list[low];
else {
max = largest(list, low + 1, high);
if (list[low] >= max)
return list[low];
else
return max;
}
}
/*void output() {
for (int x = 0; x < 10; x++) {
cout << "Name" << setw(50) << "ID" << setw(50) << "Grade" << endl;
cout << Students[x].SLname << setw(30) << right << "," << Students[x].SFname << setw(50) << Students.Sid << setw(50) << Students.fgrade << endl;
}
}*/

void gradecalc(student Students[]) {
int x=0;
for (int x = 0; x < 10; x++) {
if (Students[x].fgrade <= 100 && Students[x].fgrade >= 90)
Students[x].lgrade = 'A';
else if (Students[x].fgrade >= 80 && Students[x].fgrade <= 89)
Students[x].lgrade = 'B';
else if (Students[x].fgrade >= 70 && Students[x].fgrade <= 79)
Students[x].lgrade = 'C';
else if (Students[x].fgrade >= 60 && Students[x].fgrade <= 69)
Students[x].lgrade = 'D';
else if (Students[x].fgrade >= 0 && Students[x].fgrade <= 59)
Students[x].lgrade = 'F';
cout << "Student " << x + 1 << " grade is " << Students[x].lgrade << endl;
}

//need an array with largest function not sure what

}

Here is an array,

 
Students[value].fgrade; // value is the nth student. fgrade is their letter grade. 


Trying using a nested for loop with an if...else if statement.
Last edited on
okay so i attempted to implement the largest function and i cant get it to work. any ideas?
#include <iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;
struct student {
string SFname;
string SLname;
int Sid;
double sgrade[4];
double fgrade;
char lgrade;
};


//void output();
int largest(const int list[], int low, int high);
void input(student Students[], int &x);
void Calc(student Students[]);
void gradecalc(student Students[]);

int main()
{
double fgrade = 0.0;
int x = 0;
//double fgrade;
student Students[10];
input(Students, x);
Calc(Students);
gradecalc(Students);


cin.get(); cin.get();
return 0;
}
void input(student Students[], int &x){

for (int x = 0; x < 10; x++) {
cout << "Please enter Students first name" << endl;
cin >> Students[x].SFname;
cout << "Please enter Students last name" << endl;
cin >> Students[x].SLname;
cout << "Please enter the Students ID" << endl;
cin >> Students[x].Sid;
cout << "Please enter the students first grade" << endl;
cin >> Students[x].sgrade[0];
cout << "Please enter the students second grade" << endl;
cin >> Students[x].sgrade[1];
cout << "Please enter the students third grade" << endl;
cin >> Students[x].sgrade[2];
cout << "Please enter the students fourth grade" << endl;
cin >> Students[x].sgrade[3];

}

}
void Calc(student Students[]){

double grade=0.0;
double total;
total = 0;
for (int x = 0; x < 10; x++) {

total = Students[x].sgrade[0] + Students[x].sgrade[1] + Students[x].sgrade[2] + Students[x].sgrade[3];

Students[x].fgrade = total / 4;


}
return ;
}

int largest(student Students[], int low, int high) {
int max;
if (low == high)
return Students[low];
else {
max = largest(Students, low + 1, high);
if (Students[low] >= max)
return Students[low];
else
return max;
}
}
void output() {
for (int x = 0; x < 10; x++) {
cout << "Name" << setw(50) << "ID" << setw(50) << "Grade" << endl;
cout << Students[x].SLname << setw(30) << right << "," << Students[x].SFname << setw(50) << Students.Sid << setw(50) << Students.fgrade << endl;
}
}

void gradecalc(student Students[]) {
int x=0;
for (int x = 0; x < 10; x++) {
if (Students[x].fgrade <= 100 && Students[x].fgrade >= 90)
Students[x].lgrade = 'A';
else if (Students[x].fgrade >= 80 && Students[x].fgrade <= 89)
Students[x].lgrade = 'B';
else if (Students[x].fgrade >= 70 && Students[x].fgrade <= 79)
Students[x].lgrade = 'C';
else if (Students[x].fgrade >= 60 && Students[x].fgrade <= 69)
Students[x].lgrade = 'D';
else if (Students[x].fgrade >= 0 && Students[x].fgrade <= 59)
Students[x].lgrade = 'F';
cout << "Student " << x + 1 << " grade is " << Students[x].lgrade << endl;
}

for (int x = 0; x < 10; x++) {
Students[x].fgrade = largest
}
//need an array with largest function not sure what

}
This would have been my idea,

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
// Header files
#include <iostream>
#include<string>
// Using namespace standard
using namespace std;
// Structure student
struct student
{
string SFname;
string SLname;
int Sid;
double sgrade[4]; // Hold four grades only
double fgrade; // Final grade score
char lgrade; // Letter grade
};
// Function header
void input(student Students[], int &x); // X is passed by reference
void finalGrade(student Students[]);
void letterGrade(student Students[]);
char bestStudent(student Students[]);
// Main
int main()
{
	// Variable initiliazed to zero because it is a counter.
	int x = 0;
	char highest;
	// Constant declared and initialized.
	const int MAX_STUDENTS = 10;
	// Object declared
	student Students[MAX_STUDENTS];
	// 10 function calls
	input(Students, x); // When students is passed, it passes the array.
	// Final grade calculator.
	finalGrade(Students);
	// Letter grade
	letterGrade(Students);
	// Best student
	highest = bestStudent(Students);
	
	cout << "Best student had an " << highest << "!";
	
return 0;
}
// Function
void input(student Students[], int &x) // X is passed by reference
{
	for (x = 0; x < 10; x++)
	{
		// Enter data into structure!
		cout << "Please enter Students first name ";
		cin >> Students[x].SFname;
		cout << "Please enter Students last name ";
		cin >> Students[x].SLname;
		cout << "Please enter the Students ID ";
		cin >> Students[x].Sid;
		cout << "Please enter the students first grade ";
		cin >> Students[x].sgrade[0];
		cout << "Please enter the students second grade ";
		cin >> Students[x].sgrade[1];
		cout << "Please enter the students third grade ";
		cin >> Students[x].sgrade[2];
		cout << "Please enter the students fourth grade ";
		cin >> Students[x].sgrade[3];
		cout << endl << endl;
	}
	
}
// Final grade function
void finalGrade(student Students[])
{	
	// Local variables.
	int i;
	double totalVar = 0; // Initialized to zero
	// For loop to determine final grades.
	for (i = 0; i < 10; i++)
	{
		// Temporarily store the students grade percentage total in a variable.
		totalVar = Students[i].sgrade[0] + Students[i].sgrade[1] + Students[i].sgrade[2] + Students[i].sgrade[3];
		Students[i].fgrade = totalVar / 4; // Average grade is the final grade
	}
}
// Letter grade function
void letterGrade(student Students[])
{
	// Local variables
	int i;
	// For loop goes through all the students and assigns a grade.
	for (i = 0; i < 10; i++)
	{
		// If...else if statement that determines the grade of students.
		if (Students[i].fgrade <= 100 && Students[i].fgrade >= 90)
			Students[i].lgrade = 'A';
		else if (Students[i].fgrade >= 80 && Students[i].fgrade <= 89)
			Students[i].lgrade = 'B';
		else if (Students[i].fgrade >= 70 && Students[i].fgrade <= 79)
			Students[i].lgrade = 'C';
		else if (Students[i].fgrade >= 60 && Students[i].fgrade <= 69)
			Students[i].lgrade = 'D';
		else if (Students[i].fgrade >= 0 && Students[i].fgrade <= 59)
			Students[i].lgrade = 'F';
		cout << endl << "Student " << i + 1 << " grade is " << Students[i].lgrade << endl;
	}
}
// Best student function
char bestStudent(student Students[])
{
	// Local variables
	int i,
		j;
	// For loop to determine who has the highest score.
	for (i = 0; i < 10; i++)
	{
		for (j = 0; j < 10; j++)
		{
			if (Students[i].fgrade <=! Students[j].fgrade)
				return Students[i].lgrade;
		}
	}	
}

Last edited on
So i added the beststudent function and didnt get an output. one more issue i think we may come across on the out put i need to state the students name. do you know of any way of isolating the student who had the best score? that way when we implement the output function we can easily add it?
I changed 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
// Header files
#include <iostream>
#include<string>
// Using namespace standard
using namespace std;
// Structure student
struct student
{
string SFname;
string SLname;
int Sid;
double sgrade[4]; // Hold four grades only
double fgrade; // Final grade score
char lgrade; // Letter grade
};
// Function header
void input(student Students[], int &x); // X is passed by reference
void finalGrade(student Students[]);
void letterGrade(student Students[]);
void bestStudent(student Students[]);
// Main
int main()
{
	// Variable initiliazed to zero because it is a counter.
	int x = 0;
	char highest;
	// Constant declared and initialized.
	const int MAX_STUDENTS = 10;
	// Object declared
	student Students[MAX_STUDENTS];
	// 10 function calls
	input(Students, x); // When students is passed, it passes the array.
	// Final grade calculator.
	finalGrade(Students);
	// Letter grade
	letterGrade(Students);
	// Best student
	bestStudent(Students);
	
return 0;
}
// Function
void input(student Students[], int &x) // X is passed by reference
{
	for (x = 0; x < 10; x++)
	{
		// Enter data into structure!
		cout << "Please enter Students first name ";
		cin >> Students[x].SFname;
		cout << "Please enter Students last name ";
		cin >> Students[x].SLname;
		cout << "Please enter the Students ID ";
		cin >> Students[x].Sid;
		cout << "Please enter the students first grade ";
		cin >> Students[x].sgrade[0];
		cout << "Please enter the students second grade ";
		cin >> Students[x].sgrade[1];
		cout << "Please enter the students third grade ";
		cin >> Students[x].sgrade[2];
		cout << "Please enter the students fourth grade ";
		cin >> Students[x].sgrade[3];
		cout << endl << endl;
	}
	
}
// Final grade function
void finalGrade(student Students[])
{	
	// Local variables.
	int i;
	double totalVar = 0; // Initialized to zero
	// For loop to determine final grades.
	for (i = 0; i < 10; i++)
	{
		// Temporarily store the students grade percentage total in a variable.
		totalVar = Students[i].sgrade[0] + Students[i].sgrade[1] + Students[i].sgrade[2] + Students[i].sgrade[3];
		Students[i].fgrade = totalVar / 4; // Average grade is the final grade
	}
}
// Letter grade function
void letterGrade(student Students[])
{
	// Local variables
	int i;
	// For loop goes through all the students and assigns a grade.
	for (i = 0; i < 10; i++)
	{
		// If...else if statement that determines the grade of students.
		if (Students[i].fgrade <= 100 && Students[i].fgrade >= 90)
			Students[i].lgrade = 'A';
		else if (Students[i].fgrade >= 80 && Students[i].fgrade <= 89)
			Students[i].lgrade = 'B';
		else if (Students[i].fgrade >= 70 && Students[i].fgrade <= 79)
			Students[i].lgrade = 'C';
		else if (Students[i].fgrade >= 60 && Students[i].fgrade <= 69)
			Students[i].lgrade = 'D';
		else if (Students[i].fgrade >= 0 && Students[i].fgrade <= 59)
			Students[i].lgrade = 'F';
		cout << endl << "Student " << i + 1 << " grade is " << Students[i].lgrade << endl;
	}
}
// Best student function
void bestStudent(student Students[])
{
	// Local variables
	int i,
		j;
	// For loop to determine who has the highest score.
	for (i = 0; i < 10; i++)
	{
		for (j = 0; j < 10; j++)
		{
			if (Students[i].fgrade <=! Students[j].fgrade)
				cout << "Student " << i + 1 << " had the highest score with an " << Students[i].lgrade << " letter grade.";
		}
	}	
}


This certainly has changed a lot since you wrote this post. I also did not know much about structures and learned them to provide you with help this evening. If it doesn't work let me know. I am not sure why it wouldn't be working.
Last edited on
I see what you mean now.
yes this project is almost done! i only need to finish this part and add an output you have been a tremendous help! and i honestly couldnt have done it without you! i did add your changes and it is acting as if the function isnt being called at all #include <iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;
struct student {
string SFname;
string SLname;
int Sid;
double sgrade[4];
double fgrade;
char lgrade;
};


//void output();
//int largest(const int list[], int low, int high);
void input(student Students[], int &x);
void Calc(student Students[]);
void gradecalc(student Students[]);
char bestStudent(student Students[]);
int main()
{
char highest;
double fgrade = 0.0;
int x = 0;
//double fgrade;
student Students[10];
input(Students, x);
Calc(Students);
gradecalc(Students);
bestStudent(Students);


cin.get(); cin.get();
return 0;
}
void input(student Students[], int &x){

for (int x = 0; x < 10; x++) {
cout << "Please enter Students first name" << endl;
cin >> Students[x].SFname;
cout << "Please enter Students last name" << endl;
cin >> Students[x].SLname;
cout << "Please enter the Students ID" << endl;
cin >> Students[x].Sid;
cout << "Please enter the students first grade" << endl;
cin >> Students[x].sgrade[0];
cout << "Please enter the students second grade" << endl;
cin >> Students[x].sgrade[1];
cout << "Please enter the students third grade" << endl;
cin >> Students[x].sgrade[2];
cout << "Please enter the students fourth grade" << endl;
cin >> Students[x].sgrade[3];

}

}
void Calc(student Students[]){

double grade=0.0;
double total;
total = 0;
for (int x = 0; x < 10; x++) {

total = Students[x].sgrade[0] + Students[x].sgrade[1] + Students[x].sgrade[2] + Students[x].sgrade[3];

Students[x].fgrade = total / 4;


}
return ;
}

/*int largest(student Students[], int low, int high) {
int max;
if (low == high)
return Students[low];
else {
max = largest(Students, low + 1, high);
if (Students[low] >= max)
return Students[low];
else
return max;
}
}*/
/*void output() {
for (int x = 0; x < 10; x++) {
cout << "Name" << setw(50) << "ID" << setw(50) << "Grade" << endl;
cout << Students[x].SLname << setw(30) << right << "," << Students[x].SFname << setw(50) << Students.Sid << setw(50) << Students.fgrade << endl;
}
}*/

void gradecalc(student Students[]) {
int x=0;
for (int x = 0; x < 10; x++) {
if (Students[x].fgrade <= 100 && Students[x].fgrade >= 90)
Students[x].lgrade = 'A';
else if (Students[x].fgrade >= 80 && Students[x].fgrade <= 89)
Students[x].lgrade = 'B';
else if (Students[x].fgrade >= 70 && Students[x].fgrade <= 79)
Students[x].lgrade = 'C';
else if (Students[x].fgrade >= 60 && Students[x].fgrade <= 69)
Students[x].lgrade = 'D';
else if (Students[x].fgrade >= 0 && Students[x].fgrade <= 59)
Students[x].lgrade = 'F';
cout << "Student " << x + 1 << " grade is " << Students[x].lgrade << endl;
}


//need an array with largest function not sure what

}

char bestStudent(student Students[])
{
// Local variables
int x,
y;
// For loop to determine who has the highest score.
for (x = 0; x < 10; x++)
{
for (y = 0; y < 10; y++)
{
if (Students[x].fgrade <= !Students[y].fgrade)
cout << "Student " << x + 1 << " had the highest score with an " << Students[x].fgrade << " letter grade.";
}
}
return 0;
i do hope you can stick around a bit longer i could use the help!
I am around, I am just trying to figure out why it won't display. It is a logic error.
basically all i need to do now is figure out a way to isolate the student with the highest grade and then funnel it all into one big output function to make it all look nice. 
could we potentially save it to a string variable then just add the string to the output function?
im not sure how it would work but i seems like the only way. or maybe even make it a function itself. resave it and then output it in a final product
Try 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
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
// Header files
#include <iostream>
#include<string>
// Using namespace standard
using namespace std;
// Structure student
struct student
{
string SFname;
string SLname;
int Sid;
double sgrade[4]; // Hold four grades only
double fgrade; // Final grade score
char lgrade; // Letter grade
};
// Function header
void input(student Students[], int &x); // X is passed by reference
void finalGrade(student Students[]);
void letterGrade(student Students[]);
void bestStudent(student Students[]);
// Main
int main()
{
	// Variable initiliazed to zero because it is a counter.
	int x = 0;
	char highest;
	// Constant declared and initialized.
	const int MAX_STUDENTS = 10;
	// Object declared
	student Students[MAX_STUDENTS];
	// 10 function calls
	input(Students, x); // When students is passed, it passes the array.
	// Final grade calculator.
	finalGrade(Students);
	// Letter grade
	letterGrade(Students);
	// Best student
	bestStudent(Students);
	
return 0;
}
// Function
void input(student Students[], int &x) // X is passed by reference
{
	// Enter data for ten students.
	for (x = 0; x < 10; x++)
	{
		cout << "Please enter Students first name ";
		cin >> Students[x].SFname;
		cout << "Please enter Students last name ";
		cin >> Students[x].SLname;
		cout << "Please enter the Students ID ";
		cin >> Students[x].Sid;
		cout << "Please enter the students first grade ";
		cin >> Students[x].sgrade[0];
		cout << "Please enter the students second grade ";
		cin >> Students[x].sgrade[1];
		cout << "Please enter the students third grade ";
		cin >> Students[x].sgrade[2];
		cout << "Please enter the students fourth grade ";
		cin >> Students[x].sgrade[3];
		cout << endl << endl;
	}
}
// Final grade function
void finalGrade(student Students[])
{	
	// Local variables.
	int i;
	double totalVar = 0; // Initialized to zero
	// For loop to determine final grades.
	for (i = 0; i < 10; i++)
	{
		// Temporarily store the students grade percentage total in a variable.
		totalVar = Students[i].sgrade[0] + Students[i].sgrade[1] + Students[i].sgrade[2] + Students[i].sgrade[3];
		Students[i].fgrade = totalVar / 4; // Average grade is the final grade
	}
}
// Letter grade function
void letterGrade(student Students[])
{
	// Local variables
	int i;
	// For loop goes through all the students and assigns a grade.
	for (i = 0; i < 10; i++)
	{
		// If...else if statement that determines the grade of students.
		if (Students[i].fgrade <= 100 && Students[i].fgrade >= 90)
			Students[i].lgrade = 'A';
		else if (Students[i].fgrade >= 80 && Students[i].fgrade <= 89)
			Students[i].lgrade = 'B';
		else if (Students[i].fgrade >= 70 && Students[i].fgrade <= 79)
			Students[i].lgrade = 'C';
		else if (Students[i].fgrade >= 60 && Students[i].fgrade <= 69)
			Students[i].lgrade = 'D';
		else if (Students[i].fgrade >= 0 && Students[i].fgrade <= 59)
			Students[i].lgrade = 'F';
		cout << endl << "Student " << i + 1 << " grade is " << Students[i].lgrade << endl; // Output line.
	}
}
// Best student function
void bestStudent(student Students[])
{
	// Local variables
	int i,
		j;
	// Separated to initialize
	double	highScore = Students[0].fgrade; // Set the highest score to the first element in the array.
	// For loop to determine who has the highest score.
	for (i = 0; i < 10; i++)
	{
		// Determines if the next element is higher.
		if (Students[i].fgrade > highScore)
			highScore = Students[i].fgrade; // If it is higher, then it assigns to highScore.
	}	
	cout << "The highest score was a " << Students[i].fgrade; // Output line.
}


Edit: I forgot to change a line.
Edit: I also did not add the output function and just helped you write the function. If you want that output function you will have to make changes. (You will make use of return statements and change the functions return types. Because I want to see you try it.)
Last edited on
i get errors that say highScore is a undeclared identifier
#include <iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;
struct student {
string SFname;
string SLname;
int Sid;
double sgrade[4];
double fgrade;
char lgrade;
};


//void output();
//int largest(const int list[], int low, int high);
void input(student Students[], int &x);
void Calc(student Students[]);
void gradecalc(student Students[]);
char bestStudent(student Students[]);
int main()
{

double fgrade = 0.0;
int x = 0;
//double fgrade;
student Students[10];
input(Students, x);
Calc(Students);
gradecalc(Students);
bestStudent(Students);


cin.get(); cin.get();
return 0;
}
void input(student Students[], int &x){

for (int x = 0; x < 10; x++) {
cout << "Please enter Students first name" << endl;
cin >> Students[x].SFname;
cout << "Please enter Students last name" << endl;
cin >> Students[x].SLname;
cout << "Please enter the Students ID" << endl;
cin >> Students[x].Sid;
cout << "Please enter the students first grade" << endl;
cin >> Students[x].sgrade[0];
cout << "Please enter the students second grade" << endl;
cin >> Students[x].sgrade[1];
cout << "Please enter the students third grade" << endl;
cin >> Students[x].sgrade[2];
cout << "Please enter the students fourth grade" << endl;
cin >> Students[x].sgrade[3];

}

}
void Calc(student Students[]){

double grade=0.0;
double total;
total = 0;
for (int x = 0; x < 10; x++) {

total = Students[x].sgrade[0] + Students[x].sgrade[1] + Students[x].sgrade[2] + Students[x].sgrade[3];

Students[x].fgrade = total / 4;


}
return ;
}

/*int largest(student Students[], int low, int high) {
int max;
if (low == high)
return Students[low];
else {
max = largest(Students, low + 1, high);
if (Students[low] >= max)
return Students[low];
else
return max;
}
}*/
/*void output() {
for (int x = 0; x < 10; x++) {
cout << "Name" << setw(50) << "ID" << setw(50) << "Grade" << endl;
cout << Students[x].SLname << setw(30) << right << "," << Students[x].SFname << setw(50) << Students.Sid << setw(50) << Students.fgrade << endl;
}
}*/

void gradecalc(student Students[]) {
int x=0;
for (int x = 0; x < 10; x++) {
if (Students[x].fgrade <= 100 && Students[x].fgrade >= 90)
Students[x].lgrade = 'A';
else if (Students[x].fgrade >= 80 && Students[x].fgrade <= 89)
Students[x].lgrade = 'B';
else if (Students[x].fgrade >= 70 && Students[x].fgrade <= 79)
Students[x].lgrade = 'C';
else if (Students[x].fgrade >= 60 && Students[x].fgrade <= 69)
Students[x].lgrade = 'D';
else if (Students[x].fgrade >= 0 && Students[x].fgrade <= 59)
Students[x].lgrade = 'F';
cout << "Student " << x + 1 << " grade is " << Students[x].lgrade << endl;
}


//need an array with largest function not sure what

}

char bestStudent(student Students[])
{
// Local variables
// Local variables
int x,

// Separated to initialize
double highScore = Students[0].fgrade; // Set the highest score to the first element in the array.
// For loop to determine who has the highest score.
for (x = 0; x < 10; x++)
{
// Determines if the next element is higher.
if (Students[x].fgrade > highScore)
highScore = Students[x].fgrade; // If it is higher, then it assigns to highScore.
}
cout << "Student " << x + 1 << " had the highest score with an " << Students[x].lgrade << " letter grade."; // Output line.

return 0;
}
There is a line where int x does not have a semicolon after it. I have no compile errors.
okay i got the int x and it complied after entering the data the output added a student and didnt display the letter grade of said student
I know, I forgot to change that line. Look at back at my code. I am currently working on your output, but I want to see you do it.
I want to make sure that we are able the get the highest score function working. i am just really terrible at passing parameters and arrays haha.
You are learning. I am also working on your output function. What did you say it needed. I also want to see you try it before I send it.
basically like this:

PASS
-------
lastname, firstname lettergrade



FAIL
------
lastname, firstname lettergrade



HIGHEST GRADE
--------------------

lastname, firstname lettergrade


this is where i think most of the issues will come into place seeing as there is a high amount of problems with finding the highest score in the array
im looking stuff up but everything i am finding is all hard coded in and doesnt rely on user input
Pages: 123