Hello. I have written my code and I am almost done, but I keep getting LNK2019 errors. I'm not sure what I'm doing wrong. Any suggestions?

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int getStudentCount(void);
double getExamScores (int noStudents);
double getLabScores(int noStudents);
double calculatePointGrades(double, double);
char calculateLetterGrades(double);
void showGradeData(double, double, double, double);

int i, noStudents, sum=0;
double exam[100], labAvg[100], gradePt[100];
double totalLabAvg=0, totalExam=0, classLabAvg, classExamAvg;
char letterGrade[100];


int main()
{
getStudentCount();
getExamScores(noStudents);
getLabScores(noStudents);
calculatePointGrades(exam[i], labAvg[i]);
calculateLetterGrades(gradePt[i]);
showGradeData(exam[i], labAvg[i], letterGrade[i], gradePt[i]);


	

		
	system("pause");
}

int getStudentCount()
{
	cout<< "Please enter the number of students" << endl;
	cin>> noStudents;
	cout<< endl;
	return noStudents;
}
double getExamScores(int noStudents)
{

	for (i=0; i<noStudents ; i++)
		{ 
			cout<< "Please enter the exam grade."<< endl;
			cin>> exam[i];
			cout<< endl;
		}
	return exam[i];
}
double getLabScores (int noStudents)
{
	for (i=0; i<noStudents ; i++)
		{ 
			cout<< "Please enter the lab grade."<< endl;
			cin>> labAvg[i];
			cout<< endl;
		}
	return labAvg[i];
}
double calculatePointGrades(double exam[100], double labAvg[100])
{
	for(i=0; i<noStudents; i++)
	{
		gradePt[i]= 0.70*exam[i] + 0.30*labAvg[i];
	}
	return gradePt[i];
}
char calculateLetterGrades(double gradePt[100])
{
	for (i=0; i<noStudents; i++)// calculate grade pt
	{
		
		if (gradePt[i]<= 60)
			
		{
			letterGrade[i]= 'F';
		}
		else if (gradePt[i]<= 70)
			
		{
			letterGrade[i]= 'D';
		}
		else if (gradePt[i]<= 80)
			
		{
			letterGrade[i]= 'C';
		}
		else if (gradePt[i]<= 90)
			
		{
			letterGrade[i]= 'B';
		}
		else if (gradePt[i]<= 100)
			
		{
			letterGrade[i]= 'A';
		}
		else 
		{
			cout<< "fail";
		}
	}
	return letterGrade[i];
}
void showGradeData(double exam[100], double labAvg[100], double gradePt[100], double letterGrade [100])
{
	cout<<endl<< endl
		<< "---------------------------------------------------"<<endl
		<< "-----------------------Grades----------------------"<<endl
		<< "                                                   "<<endl
		<< "Exam Grade | Lab Grade | Grade Point | Letter Grade"   <<endl;

	for (i=0; i<noStudents; i++) //print avg
		{
			cout<< setw(5) << exam[i] <<setw(5)<<"|"<<setw(5)
				<<labAvg[i] <<setw(5)<<"|"<<setw(5)<< gradePt[i]
				<<setw(5)<<"|"<<setw(5)<< letterGrade[i]<<endl<<endl;
			cout<< "---------------------------------------------------"<<endl;
			
			totalExam= totalExam+exam[i];
			totalLabAvg= totalLabAvg+labAvg[i];
		}
	 
			
		
		classExamAvg= totalExam/noStudents;
		classLabAvg= totalLabAvg/noStudents;

		cout<<endl<<endl;
		cout<< "The total lab average is: " << classLabAvg<< endl;
		cout<< "The total exam average is: " << classExamAvg<<endl;

}

Copy and paste the errors, don't make us search through 136 lines of code! lol

Sorry.

Error	2	error LNK2019: unresolved external symbol "char __cdecl calculateLetterGrades(double)" (?calculateLetterGrades@@YADN@Z) referenced in function _main	DelLongo_Patricia_w6_ilab.obj
Error	3	error LNK2019: unresolved external symbol "double __cdecl calculatePointGrades(double,double)" (?calculatePointGrades@@YANNN@Z) referenced in function _main	DelLongo_Patricia_w6_ilab.obj
Error	1	error LNK2019: unresolved external symbol "void __cdecl showGradeData(double,double,double,double)" (?showGradeData@@YAXNNNN@Z) referenced in function _main	DelLongo_Patricia_w6_ilab.obj
Error	4	fatal error LNK1120: 3 unresolved externals	C:\Users\Patricia\Desktop\DelLongo_Patricia_W6_ilab\Debug\DelLongo_Patricia_W6_ilab.exe

I fixed it but I can't remember why it wasn't working... lol. Plus it is a bit tidier now. In future you don't need a function to do every little bit of code. Functions are best used if it is something you want repeated many times. Try also to write down your code in a methodical way, rather than bits here and there. Perhaps plan out your program before you make it.

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

void calculateLetterGrades(double* gradePt, char* letterGrade);
void showGradeData(double* exam, double* labAvg, double* gradePt, char* letterGrade); 

int NUM_OF_STUDENTS;

using namespace std;

int main()
{	
	double exam[100];
	double labAvg[100];
	double gradePt[100];
	char letterGrade[100];

	cout << "Please enter the number of students\n";
	cin >> NUM_OF_STUDENTS;
	cout << endl;

	for(int i = 0; i < NUM_OF_STUDENTS; i++)
	{
		cout << "Please enter the exam grade.\n";
		cin >> exam[i];
		cout << endl;
	}

	for(int i = 0; i < NUM_OF_STUDENTS; i++)
	{
		cout << "Please enter the lab grade.\n";
		cin >> labAvg[i];
		cout << endl;
	}

	for(int i = 0; i < NUM_OF_STUDENTS; i++)
		gradePt[i] = (0.70 * exam[i]) + (0.30 * labAvg[i]);

	calculateLetterGrades(gradePt, letterGrade);
	showGradeData(exam, labAvg, gradePt, letterGrade);
     
	system("pause");
}

// write description here
void calculateLetterGrades(double* gradePt, char* letterGrade)
{
	for(int i = 0; i < NUM_OF_STUDENTS; i++)// calculate grade pt
	{
		if(gradePt[i] <= 50)
			letterGrade[i] = 'X';
		else if(gradePt[i] > 50 && gradePt[i] <= 60)
			letterGrade[i] = 'F';
		else if(gradePt[i] > 60 && gradePt[i] <= 70)
			letterGrade[i] = 'D';
		else if(gradePt[i] > 70 && gradePt[i] <= 80)
			letterGrade[i] = 'C';
		else if(gradePt[i] > 80 && gradePt[i] <= 90)
			letterGrade[i] = 'B';
		else if(gradePt[i] > 90)
			letterGrade[i] = 'A';
	}

	return;
}

// write description here
void showGradeData(double* exam, double* labAvg, double* gradePt, char* letterGrade)
{
	int totalExam = 0;
	int totalLabAvg = 0;
	int classExamAvg = 0;
	int classLabAvg = 0;

	cout << "\n\n---------------------------------------------------\n"
	<< "-----------------------Grades----------------------\n \n"
	<< "Exam Grade | Lab Grade | Grade Point | Letter Grade\n";
     
	for(int i = 0; i < NUM_OF_STUDENTS; i++) //print avg
	{
		cout << setw(5) << exam[i] << setw(5) << "|" << setw(5)
		<< labAvg[i] <<setw(5) << "|" << setw(5) << gradePt[i]
		<< setw(5) << "|" << setw(5) << letterGrade[i]
		<< "\n\n---------------------------------------------------\n";
     
		totalExam += exam[i];
		totalLabAvg += labAvg[i];
	}
     
	classExamAvg = totalExam / NUM_OF_STUDENTS;
	classLabAvg = totalLabAvg / NUM_OF_STUDENTS;
     
	cout << "\n\nThe total lab average is: " << classLabAvg
	<< "\nThe total exam average is: " << classExamAvg << endl;

	return;
}

Thank you. I know everything doesn't have to be in functions, but that's how my Prof wanted it.. Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.