Thread: Vectors:

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    499

    Vectors:

    I am trying to make a grade book and using a vector to get the grades. I am getting errors all over and I figured this would happen because this is the first time I ever used vectors.

    Code:
     
    #ifndef ___2B__Homework__LetterGrade__
    #define ___2B__Homework__LetterGrade__
    
    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    class GradeBook {
        
    public:
        void getGrades()
        {
            int numGrades=0;
            int checker;
            
            cout<< " Enter the students Grades and Enter -1 to stop. "<<endl;
            
            while (checker != -1) {
            cin>>checker;
            ++numGrades;
                
            vector<int> grades(numGrades);
                for (int i =0; i<numGrades; ++i) {
                    cin>>grades[i];
                    
                    averageGrades(grades[i],numGrades);
                }
            }
        
        }
        
        double averageGrades(int grades[],int num)
        {
            double total;
            double average;
            
            for (int i=0; i<num; ++i) {
                total += grades[i];
            }
            
            average = total / num;
            
            return average;
        }
        void letterGrade()
        {
            
        
        }
        
    private:
        
        
    };
    
    #endif
    Last edited by jocdrew21; 09-15-2013 at 11:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors in vectors - pointers and iterators
    By fisherking in forum C++ Programming
    Replies: 8
    Last Post: 07-27-2010, 09:34 AM
  2. About vectors.
    By KgNe in forum C++ Programming
    Replies: 23
    Last Post: 09-03-2008, 10:33 PM
  3. 2D Vectors
    By Coding in forum C++ Programming
    Replies: 14
    Last Post: 01-13-2008, 10:56 AM
  4. Help using Vectors
    By earth_angel in forum C++ Programming
    Replies: 3
    Last Post: 07-11-2005, 01:37 PM
  5. help with vectors please.
    By axlton in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2003, 09:58 PM