I have this program that i am writing that calculates GPAs and quality points for each course after the student enters their letter grade and credit hours.
The part i am having an issue with is the Calculation of the quality points for each course. I have the letter grades and credit hours dumped into 2 different arrays and I created a third array called QualityPts, which will be used to store the total quality points for each class.
This will be calculated by using the index position to determine the two values that will be used in the other 2 arrays. Now i am doing this a another method, and i am getting an error saying
"Not all code paths return a value".
The second error relates to my new variable "QualityPts" that is only in this new method. It says "Use of unassigned local variable".
These 2 errors are both in the method CalcQP()
.
My code is as follows:
private decimal[] grades;
private decimal[] Credits;
private decimal CalcQP()
{
decimal[] QualityPts;
string msg="The total quality Points for this course is: ";
for (int i = 0; i < grades.Length; i++)
{
QualityPts[i] = grades[i] * Credits[i];
lbQuality.Items.Add(msg + QualityPts[i]);
}
}