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';

}

Recommended Answers

All 2 Replies

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

And your point is what ?????

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.