I'm a little confused here. Anyone give me an hint on how to find the minimum of the grade out of all of the students and find the highest grade. Just a hint, and I will try to figure it out. If not I might ask for a possible solution :(
//Outputing data names that will be outputted on the screen. For instance, name, grades, letter grade
cout<< " Student Statistics: " << endl <<endl<<endl;
cout<< "Name\t" << "\tTest" << "\t Assignments" << "\t Points" <<"\t Numeric " <<"\tLetter ";
cout<< endl << "\t\t Avg" << "\t Avg"<< "\t\t\t Grd" << "\t\t Grd ";
//Enter in first name and last name in the filetxt
fin>>firstname >>lastname;
fin>>testgrade1 >>testgrade2;
fin>> assign1 >>assign2>>assign3;
//Going into the while loop.
while (fin)
{
//Print out the first and last name of the student
cout<<left;
cout<< "\n\n" << setw(6)<< firstname <<setw(5) <<lastname;
//Calculate the testaverage. Round it to two decimal places, with trailing zeroes
testaverage=(testgrade1+testgrade2)/2;
cout<<setprecision(2) <<fixed<<showpoint;
cout<<right<<setw(10) <<testaverage;
//Calculate the assignment average of each student
assignaverage=(assign1+assign2+assign3)/3;
cout<< setw(15);
cout<<assignaverage;
//Calculate the total points accumalated
totalpoints= testgrade1+testgrade2+assign1+assign2+assign3;
cout<< setw(16) <<totalpoints;
//Calculate the the numericgrade. Add up assignments and test, then divide by 5 to find the numericavg grade
numericgrade= (testgrade1+testgrade2+assign1+assign2+assign3)/5;
cout<< setw(12) <<numericgrade;
//Let the minimum equal numericgrade
minimum=numericgrade;
//you will use the if and else statement to calculate the letter grade
//If number is higher then 90. Student gets an A
if(numericgrade>=90)
cout<<setprecision(15)<<"\t A";
//If number is higher then 80. Students gets a B
elseif (numericgrade>=80)
cout<<setprecision(15)<<"\t B";
//If number is higher then 70. Student gets a C
elseif (numericgrade>=70)
cout<<setprecision(15)<<"\t C";
//Any lower then 70, gets an F
else
{
cout<<setprecision(15)<<"\t F";
}
counter++;
//Prevent the loop from becoming an infinite loop. Enter in names, scores, etc...
fin>>firstname >>lastname;
fin>> testgrade1 >>testgrade2;
fin>> assign1 >>assign2>>assign3;
//Add counter++ to determine the total number of students
}
//Overall Class Statistics output
//Display Class Statistic on console
cout<<"\n\n\n\tClass Statistics ";
//Display number of students in class and the calculation of total students
cout<<"\n\n\t\tNumber: "<< counter;
_getch();
return 0;
}
You will need two variables, minimum, initialized to the highest grade possibility and maximum, initialized to 0.
During your loop, check the grade of the current student to minimum. If it is smaller than minimum, set minimum to this student's grade.
Similarly, If it is larger than maximum, set maximum to this student's grade.
At the end of the loop minimum and maximum will contain the lowest and highest grade respectively.
Hope that helps, please do let us know if you require any further help.