LightbulbHelp With Grade Averager

Posts 1–8 of 8 · Page 1 of 1
Help With Grade Averager
hey guys I need some help with this code I have to make it so it takes 10 grades averages them and tells you what the letter grade is, and then list every grade.



Code:
//Hello_World Project
//Jull 4 2011
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;

int main() 
	{
	// constants
	const int numGrades = 10;
	const int greating = "Welcome To The Test Grader-5000";
	//The Variables Begins
	int dead;
	int average;
	int total;
	int grade[numGrades];
	int runningAverage = 0;
	//Code Begins 
	cout<< greating << endl;
	Sleep(1200);
	cout << "Please Enter Your Test Grade" << endl;
	
	for (int i = 0; i < 10;  i++)
	{
		cout << "Enter Grades " << (i + 1) << ": "; 
		cin >> grade[i];
		runningAverage += grade[i];
	}
	
	for (int i = 0; i < 10;  i++)
	{
		cout << grade[i] << "  ";
	}

	cout << endl;
	average = runningAverage / numGrades;

	if (average >= 90)
	{
		cout << "Average Is " << average << " Which is an A.... Thats Impresive" << endl;
	}	
	else if (average >= 80)
	{
		cout << "Average Is " << average << " Which is a B.... Well Your Atleast Above Average" << endl;
	}	
	else if (average >= 70)
	{
		cout << "Average Is " << average << " Which is a C.... Well Your Average" << endl;
	}	
	else if (average >= 60)
	{
		cout << "Average Is " << average << " Which is a D.... Well Atleast Its a D" << endl;
	}	
	else if (average >= 50)
	{
		cout << "Average Is " << average << " Which is a F.... Good Job You Dumb  @#!*% " << endl;
	}
	else if (average <= 50)
	{
		cout << "Average Is " << average << " Which is a F.... Good Job You Dumb  @#!*% " << endl;
	}


}
"const int greating = "Welcome To The Test Grader-5000";"
Thats a string which you cant save in int. Use char* instead.
thanks man your awesome
i lol'd at the line of if thier grade is an F

and instead of doing something like
Code:
int x;
int y;
int z;
you can declare all variables of the same type at once, by doing
Code:
int x, y, z;
the arrays dont count as the same type [i think]
- try this program again with cases instead of if statements (good practice)
- *not really important* try to use "unsigned short int dead, average, total;"

- this wont make a difference now, but when you're making programs that take 90 minutes to compile, you want to try to minimize memory usage. If you dont understand what I am saying, think about it like this. an int takes up usually 4 bytes of memory, now an unsigned short int takes up about 2 bytes. Doesn't sound like a lot, but I made a text based rpg, and I had tons and tons of variables. Might as well get in the habit of doing it now.
The size of a datatype has no influence whatsoever on the compile time.
The statements
Code:
else if (average >= 50)
{
message...
}
else if (average <= 50)
{
same message...
}
Can be replaced by
Code:
else
{
message...
}
Yours isn't incorrect, just a little longer than necessary.
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us