Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Array Help (http://www.go4expert.com/forums/array-help-t21739/)

jongym 12Apr2010 22:21

Array Help
 
Hi I have this lab for my comp 122 class, I am supposed to make an array of students grades. I have to input scores from tests and then labs and then have to figure out the averages. I have pretty much the whole program worked out but I keep getting compilation errors.


* Write a program that asks the user how many students
* to process, then reads in the scores for two items, u
* an exam score and lab average, for that many students,
* then calculates and displays a table of the students’
* grade information.
*
* Input: Numeric menu items from the keyboard
*
* Output: Table of entered scores and calculated grades
*
************************************************** ************************/
Code:

#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[]);
int getLabScores(int,double[]);
int calculatePointGrades(double[], double[], int, double[]);
int calculateLetterGrades(double[],char[], int);
int 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;
//getStudentCount(numStudents);

getExamScores(numStudents,arrayExamAve);
//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 Lab scores from user, loads the array
    cout << "Please enter the Lab grades for each student:"<< endl;
    for (int eScores = 0; eScores <numStudents; eScores++){
        cout<<"student "<<eScores+1<<" grade=";
        cin >> arrayLab[eScores];
        cout << endl;// this statement is used for intial test and debugging
    }
}
 
int 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
}
 
int 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];
//
//}


virxen 13Apr2010 00:31

Re: Array Help
 
same project,same solution,same variables...xm maybe the same person?

http://www.go4expert.com/showthread.php?t=21729

shabbir 13Apr2010 08:37

Re: Array Help
 
Not same ip and so only thread closed.


All times are GMT +5.5. The time now is 03:08.