numStudents // good num_students // also fine lastName // good GPA // good, since its a pretty standard abbreviation ns // not so good the_number_of_students_in_the_class_im_taking // god help us...
for (int i = 0; i < 10; i++)
calculateGrade printReport maximum factorial
x = temp; // set x to temp <---- well, DUH!
int test1, test2, final; // for user entry of test scores double average; // for storing the calculated test average int i; // loop counter
int num1, num2, num3; // user entered numbers
double average; // calculated average of the numbers
int score1, // score on exam 1
score2; // score on exam 2
Bad:
int num1, num2, num3; // user entered numbers
double average; // calculated average of the numbers
int score1, // score on exam 1
score2; // score on exam 2
Note that this second one looks junky and cluttered. Harder to read.
/* This function takes in a fahrenheit temperature (fahr)
* and returns the equivalent temperature converted
* to the celsius scale
*/
double convertToCelsius(double fahr)
{
...
}
{
int length, width;
int area;
// now another block, just for fun
{
System.out.print("Woo hoo!");
area = length * width;
}
System.out.print("Area = " + area);
}