1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Array Help

Discussion in 'C++' started by jongym, Apr 12, 2010.

Thread Status:
Not open for further replies.
  1. jongym

    jongym New Member

    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];
    //
    //}
     
    Last edited by a moderator: Apr 13, 2010
  2. virxen

    virxen New Member

  3. shabbir

    shabbir Administrator Staff Member

    Not same ip and so only thread closed.
     
Thread Status:
Not open for further replies.

Share This Page