1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
#include<iostream>
#include<iomanip>
#define MAX_STUDENTS 20 //sets a default value that can be used for initializing the arrays
using namespace std;
int getStudentCount();
void getExamScores(int, double[]);
void getLabScores(int,double[]);
void calculatePointGrades(double[], double[], int, double[]);
void calculateLetterGrades(double[],char[], int);
void showGradeData(double[],double[],char[], double[],int);
double arrayExamAve(int, double[]);
double arrayLabAve(int, double[]);
void arrayPointGrades(char[], double[], int);
char arrayLetterGrades(double[]);
// Declare functions here, include the necessary parameters here and in the actual functions below.
// (once the function prototypes are created, the main()
// function can be moved back to the top of the code.)
// Declare the arrays here
int main(){ // controls program sequence (can be moved back to the top once the function parameters are defined.)
int numStudents = getStudentCount();
cout << "You entered: " << numStudents <<" Students!" <<endl;
double arrayExam[numStudents];
getExamScores(numStudents,arrayExam);
double arrayLab[numStudents];
getLabScores(numStudents,arrayLab);
//getLabScores(numStudents,arrayLabAve[lScores]);
//calculatePointGrades(arrayLabAve[lScores],arrayExamAve[eScores],getStudentCount,arrayPointGrades[grades]);
//calculateLetterGrades(arrayPointGrades[grades],arrayLetterGrades[grades],getStudentCount);
//showGradeData(arrayExamAve[eScores],arrayLabAve[lScores],arrayLetterGrades[grades],arrayPointGrades[grades],getStudentCount);
cout<<"processing has completed in main()"<<endl;// this statement is used for intial test and debugging
cin.ignore(2);
}
int getStudentCount(){// Ask for and store the number of students from user
int numStudents= 0;
while (numStudents<1 || numStudents>MAX_STUDENTS){
cout << "Please enter the number of students: ";
cin >> numStudents;
}
cout << endl;// this statement is used for intial test and debugging
return numStudents; // returns the user entered number of students to main
}
void getExamScores(int numStudents, double *arrayExam){// Gets exam scores from user, loads the array
cout << "Please enter the exam grades for each student:"<< endl;
for (int eScores = 0; eScores <numStudents; eScores++){
cout<<"student "<<eScores+1<<" grade=";
cin >> arrayExam[eScores];
cout << endl;// this statement is used for intial test and debugging
}
}
void getLabScores(int numStudents, double *arrayLab){// Gets exam scores from user, loads the array
cout << "Please enter the exam grades for each student:"<< endl;
for (int lScores = 0; lScores <numStudents; lScores++){
cout<<"student "<<lScores+1<<" grade=";
cin >> arrayLab[lScores];
cout << endl;// this statement is used for intial test and debugging
}
}
void calculatePointGrades(double arrayLabAve[], double arrayExamAve[], int getStudentCount,double arrayPointGrades[] )// Calculates the student's numeric grade, loads the point grade array
{
// int grade=0;
// int sum=0;
// int pointGrade=0;
// for (sum = 0; sum <= numStudents; sum++)
// { sum = arrayLabAve[] + arrayExamAve[];
// pointGrade = sum/2;
// cin >> arrayPointGrades[grade];
// cout << endl;
// }
//
//// this statement is used for intial test and debugging
//return; // returns no values to main
}
void calculateLetterGrades(double arrayPointGrades[],char arrayLetterGrades[], int getStudentCount)// Determines the student's letter grade, loads the array
{
char A,B,C,D,F;
int grade;
arrayPointGrades[grade];
if (grade >= 90)
cout << 'A';
else if (grade >= 80)
cout << 'B';
else if (grade >= 70)
cout << 'C';
else if (grade >= 60)
cout << 'D';
else
cout << 'F' << endl;
cin >> arrayLetterGrades[grade];
return 0;
// this statement is used for intial test and debugging
// returns no values to main
}
//void showGradeData(double arrayExamAve[],double arrayLabAve[],char arrayLetterGrades[], double arrayPointGrades[],int getStudentCount )// Prints a table of the student's scores and grades from the arrays
//{
// cout << arrayExamAve[eScores] << arrayLabAve[lScores] << arrayLetterGrades[grades] << arrayPointGrades[grades];
// cout <<endl;// this statement is used for intial test and debugging
// // returns no values to main
//}
double arrayExamAve(int numStudents,double arrayExamAve[]) // Averages the student's numeric exam grades from the array
{
int eScores=0;
int sum=0;
double ave=0;
for (sum = 0; sum <= numStudents; sum++)
{ sum = sum + arrayExamAve[eScores];
ave = sum/numStudents;
}
// this statement is used for intial test and debugging
return ave; // returns average exam score to main
}
double arrayLabAve(int numStudents,double arrayLabAve[])// Averages the student's numeric lab grades from the array
{
int lScores=0;
int sum=0;
double aveg=0;
for (sum = 0; sum <= numStudents; sum++)
{ sum = sum + arrayLabAve[lScores];
aveg = sum/numStudents;
}
// this statement is used for intial test and debugging
return aveg; // returns average lab score to main
}
void arrayLetterGrades(char [5], double arrayPointGrades[], int grades)
{
}
//double arrayPointGrades[double grades]
//{
//
// return arrayPointGrades[grades];
//
//}
|