yay! i was able to get it to work, thanks for the help! =]
here's what the code looks like:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
struct studentRecord //structure definition
{
int studentID;
char first_name[21];
char last_name[11];
int quiz_1;
int quiz_2;
int midterm_score;
int final_score;
int totalpts;
double percent;
char grade;
};
studentRecord student; //structure variable student
//declaring constants
const int maxpts = 200;
//declare function prototypes
bool moreStudents();
void getInput(studentRecord &myStudent);
int computePointsEarned(int quiz_1, int quiz_2, int midterm_score, int final_score);
double computePercent(int totalpts, int);
void displayRecord(studentRecord);
int computeHighestPoints(int numbers1, int numbers2);
int computeLowestPoints(int numbers1, int numbers2);
double computeAveragePoints(int allPoints, int totalStudents);
double computeAveragePercent (double avgPoints, int);
char computeGrade(double input);
void displayTotals(int totalStudents, double highest, double lowest,
double avgPoints, char avgGrade);
int main()
{
//declare variables
int totalStudents = 0;
int highest = 0;
int lowest = 0;
int allPoints = 0;
double avgPoints;
double avgPercent;
char avgGrade;
//adjusts number output
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
do
{
getInput(student);
student.totalpts = computePointsEarned(student.quiz_1, student.quiz_2,
student.midterm_score, student.final_score);
student.percent = computePercent(student.totalpts, maxpts);
student.grade = computeGrade(student.percent);
lowest = computeLowestPoints(student.totalpts, highest);
highest = computeHighestPoints(highest, student.totalpts);
displayRecord(student);
totalStudents++; //add 1 to student counter
allPoints = allPoints + student.totalpts; //accumulates total class points
avgPoints = computeAveragePoints(allPoints, totalStudents);
avgPercent = computeAveragePercent(avgPoints, maxpts);
avgGrade = computeGrade(avgPercent);
}while(moreStudents()); //calls the moreStudents() function
displayTotals(totalStudents, highest, lowest, avgPoints, avgGrade);
system("PAUSE");
return 0;
} //end main()
//functions
bool moreStudents()
{
bool more = false;
char anotherStudent = 'n';
cout << "\n\nWould You like to enter another student? enter 'y' or 'Y' and press ENTER; \n";
cout << "if not, enter any other character and press ENTER ";
cin >> anotherStudent;
if(anotherStudent == 'y' || anotherStudent == 'Y')
more = true;
else
more = false;
return more;
} //end anotherStudent
void getInput (studentRecord &myStudent)
{
int ID;
string message = "\n\nEnter Student ID: ";
do
{
cout << message;
cin >> ID;
message = "\n\nError! Please Re-Enter Student ID (1-99999): ";
} while (ID < 1 || ID > 99999);
myStudent.studentID = ID;
//asks user to input first and last name
cout << "Enter First Name: ";
cin >> myStudent.first_name;
cout << "Enter Last Name: ";
cin >> myStudent.last_name;
//determines quiz #1 score
int Quiz1;
string message1 = "Please enter Quiz #1 score: ";
do
{
cout << message1;
cin >> Quiz1;
message1 = "\n\nError! Please Re-Enter Quiz #1 score: ";
} while (Quiz1 < 0 || Quiz1 > 25);
myStudent.quiz_1 = Quiz1;
//determines quiz #2 score
int Quiz2;
string message2 = "Please enter Quiz #2 score: ";
do
{
cout << message2;
cin >> Quiz2;
message2 = "\n\nError! Please Re-Enter Quiz #2 2core: ";
} while (Quiz2 < 0 || Quiz2 > 25);
myStudent.quiz_2 = Quiz2;
//determines midterm score
int Midterm;
string message3 = "Please enter Midterm score: ";
do
{
cout << message3;
cin >> Midterm;
message3 = "\n\nError! Please Re-Enter Midterm 2core: ";
} while (Midterm < 0 || Midterm > 50);
myStudent.midterm_score = Midterm;
//determines final score
int Final;
string message4 = "Please enter Final score: ";
do
{
cout << message4;
cin >> Final;
message4 = "\n\nError! Please Re-Enter Final score: ";
} while (Final < 0 || Final > 100);
myStudent.final_score = Final;
} //end getInput()
int computePointsEarned(int quiz1, int quiz2, int midtermScore, int finalScore)
{
//calculates total points earned
int output;
output = quiz1 + quiz2 + midtermScore + finalScore;
return output;
} //end computePointsEarned
double computePercent(int total, int max)
{
//calculates percentage
int output;
output = (total)*100/max;
return output;
} //end computePercent
char computeGrade(double input)
{
if (input >= 90)
return 'A';
else if (input >= 80)
return 'B';
else if (input >= 70)
return 'C';
else if (input >= 60)
return 'D';
else return 'F';
}//end computeGrade
int computeLowestPoints(int numbers1, int numbers2)
{
if (numbers1 <=numbers2)
return numbers1;
else
return numbers2;
}//end computeLowestPoints
int computeHighestPoints(int numbers1, int numbers2)
{
if (numbers1 >= numbers2)
return numbers1;
else
return numbers2;
}//end computeHighestPoints
double computeAveragePoints(int all, int total)
{
int output;
output = all/total;
return output;
}//end computeAveragePoints
double computeAveragePercent(double avg, int max)
{
//calculates percentage
double output;
output = (avg)*100/max;
return output;
} //end computePercent
void displayRecord(studentRecord staff)
{
//display input data
cout << "\n\nStudent ID: " << staff.studentID;
cout << "\nFirst Name: " << staff.first_name;
cout << "\nLast Name: " << staff.last_name;
cout << "\nQuiz #1 Score: " << staff.quiz_1;
cout << "\nQuiz#2 Score: " << staff.quiz_2;
cout << "\nMidterm Score: " << staff.midterm_score;
cout << "\nFinal Score: " << staff.final_score;
cout << "\nTotal Points Earned: " << staff.totalpts;
cout << "\nOverall Percentage: " << staff.percent;
cout << "\nLetter Grade: " << staff.grade;
} //end of displayRecord
void displayTotals(int totalStudents, double highest, double lowest,
double avgPoints, char avgGrade)
{
cout << "\n-------------------------------------------------\n\n";
cout << "Total Students = " << totalStudents;
cout << "\nHighest Total Points Earned = " << highest;
cout << "\nLowest Total Points Earned = " << lowest;
cout << "\nAverage Total Points Earned = " << avgPoints;
cout << "\nAverage Letter Grade Earned = " << avgGrade;
cout << "\n-------------------------------------------------\n\n";
}//end displayTotals