Hey all I have a program that I have been working on and am having some trouble with keeping count of all the users grades. I know that now I am only counting the last grade earned for each category but I want to know how to keep count of all of them so my calculations are correct. I'm hoping someone could point me in the right direction.

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

double calcBasal (double grade)
{
	
for (int x = 1; x <= 18; x++)
	{
		cout << " Enter BASAL grade #" << x << " (out of 100):";
		cin >> grade;
	}

	double total;
	total = ((grade * 5) / 100);
	cout << "Basal points: " << total << endl;


	return total;
}

double calcApes (double grade2)
{
for (int x = 1; x <= 12; x++)
	{
		cout << " Enter APES grade #" << x << " (out of 100):";
		cin >> grade2;
	}
	double total2;
	total2 = (((grade2 * 10) / 100) * 12);
	cout << "Apes points: " << total2 << endl;

	return total2;
}
double calcQuiz (double grade3)
{
for (int x = 1; x <= 8; x++)
	{
		cout << " Enter quiz grade #" << x << " (out of 100):";
		cin >> grade3;
	}
	double total3;
	total3 = (((grade3 * 10) / 100) * 8);
	cout << "Quiz points: " << total3 << endl;

	return total3;
}
double calcMini (double grade4)
{
	cout << "How many mini problems have you solved? ";
	cin >> grade4;
	double total4;
	total4 = (grade4 * 2);
	cout << "Mini-problems points: " << total4 << endl;

	return total4;
}
double calcLetterGrade(double percentage)
{

	if (percentage >= 95)
	{
		cout << "You got an A" << endl;
	}
	else if (percentage >= 90 && percentage < 95)
	{
		cout << "You got a A-" << endl;
	}
	else if (percentage >=85 && percentage < 90)
	{
		cout << "You got a B" << endl;
	}
	else if (percentage >= 80 && percentage < 85)
	{
		cout << "You got a B-" << endl;
	}
	else if (percentage >= 75 && percentage < 80)
	{
		cout << "You got a C" << endl;
	}
	else if (percentage >= 70 && percentage < 75)
	{
		cout << "You got a C-" << endl;
	}
	else if (percentage >= 65 && percentage < 70)
	{
		cout << "You got a D" << endl;
	}
	else if (percentage >= 60 && percentage < 65)
	{
		cout << "You got a D-" << endl;
	}
	else
	{
		cout << "You got a F" << endl;
	}
	return percentage;
}

int main()
{
	double grade = 0, grade2 = 0, grade3 = 0, grade4 = 0, grade5, grandTotal, percentage;
	
	grandTotal = calcBasal(grade);
	grandTotal += calcApes(grade2);
	grandTotal += calcQuiz(grade3);
	grandTotal += calcMini(grade4);
	cout << "Enter final exam grade (or a guess) (out of 100): ";
	cin >> grade5;
	grandTotal += grade5;
	cout << "Total points: " << grandTotal << endl;
	percentage = ((grandTotal / 465) * 100);
	cout << "Percentage score: " << setiosflags(ios::fixed) << setprecision(4) << percentage << endl;
	calcLetterGrade(percentage);
	
}

So your idea is to

double calcBasal (double grade)
{
	
for (int x = 1; x <= 18; x++)
	{
		cout << " Enter BASAL grade #" << x << " (out of 100):";
		cin >> grade;         // read 18 numbers and keep only the last one
	}

	double total;
	total = ((grade * 5) / 100); // multiply this one grade by .05
	cout << "Basal points: " << total << endl;


	return total;
}

Don't you need to accumulate (add) all the grades read in to get a total?

hello, the user is entering the percent they earned for each grade and I am converting that percentage to a score. I want to add all the scores up to get the total amount of points. The trouble that I'm having is I'm not sure how to add all those scores together. I thought I could simply take total += grade * 5 / 100 but I just kept getting 5 for the total points.

Well then obviously that's not how it's done.

Now if you read my comments and think about them, you should have an "aha!" moment. total += grade * 5 / 100 is kinda correct, but you need to do part of this statement in a different place.

This article has been dead for over six months. Start a new discussion instead.