0
double classAve (double g, int i);
char gradeLet (double z);

int main ()
{

	int ans, count = 0;
	double grade, numTot = 0; 

	
	
	cout<<"Do you have a grade to enter? (Yes = 1, No = 2) ";
	cin>>ans;
	cout<<endl;

		while (ans != 1 && ans != 2)
		{
			cout<<"Invalid answer given";
			cout<<endl;

			cout<<"Do you have any more grades? (Yes = 1, No = 2) ";
			cin>>ans;
			cout<<endl;
		}

	while (ans == 1)
	{
		cout<<"Please enter your grade. ";
		cin>>grade;
		cout<<endl;
		numTot = numTot + grade;
		count++;


		cout<<"Do you have any more grades? (Yes = 1, No = 2) ";
		cin>>ans;
		cout<<endl;

		


	}


	if (ans == 2 && numTot == 0)
	{
		cout<<"No grades were given.";
		cout<<endl;

	}

	double numAve = classAve(numTot, count);

	cout<<"Your numerical average is "<<numAve<<endl;

	char letGrad = gradeLet (numAve);

	cout<<"Your letter grade is: "<<letGrad<<endl;

return 0;


double classAve (double g, int i)
{
	double cheese;

	cheese = g / i;

	return cheese;
}

char gradeLet (double z)
{
	

	if (z >= 92.5)
		return 'A';

	else if (z >= 84.5)
		return 'B';

	else if (z >= 76.5)
		return 'C';

	else if (z >= 69.5)
		return 'D';

	else //(z <= 69.5 && z > 0)
		return 'F';

}
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

That's...random. I suppose you're using your first post to show off your m4d pr0gr4mm1ing sk1llz. :icon_rolleyes:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.