So I need to write a program that requires getting data from an input file (first name, last name, Student ID, and 4 test grades) and create an outputfil with the first and last names and ID, and then the average of the grades and the final letter grade - I don't need to sort them or anything.

I knew I'd have to use vectors for the names (I went for extra help at school, and was told that using .insert and .push_back was the best way to do that) and that'd it'd be easier to manupulate the numbers via arrays, but I goofed up somewhere and I'm not sure what's wrong.

I'm getting 49 errors - about half are "missing ;/}/whatever" and the rest are either issue with my usage of fout and the fact that my constants in the .insert parts are too large and I'm trying to convert int to string (which I'm not seeing how I managed that)

If anyone can tell me where exactly I'm messing up that'd be great.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iomanip>
using std::ifstream;
using std::ofstream;
using namespace std;


       

  


int main()
{

vector<string> First(10);
vector<string> Last(10);
vector<string> IDN(10);
vector<int> test1(10);
vector<int> test2(10);
vector<int> test3(10);
vector<int> test4(10);
vector<string> grades(10);
vector<double> average(10);


int A_counter;  
int B_counter;  
int C_counter;
int total; 
int i;


double scores;

double avg;



ifstream inStream;
ofstream outStream;

inStream.open("inputfile.dat");
outStream.open("output.txt");




outStream << "FirstName" << setw(9) <<
"LastName" << setw(5) << "ID" << setw(5)
<< "Average" << setw(5) << "Grade"
<<endl;

    int i = 0;
    while(!inStream.eof())
    {
        vector<string>::iterator Iterate = First.begin();
        First.insert (Iterate, 10, 'fname');
        for (Iterate = First.begin();
                Iterate != First.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        First.push_back(10);
       
   
    }

        {
        vector<string>::iterator Iterate = Last.begin();
        Last.insert (Iterate, 10, 'lname');
        for (Iterate = Last.begin();
                Iterate != Last.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        Last.push_back(10);
       
   
    }
            {
        vector<string>::iterator Iterate = IDN.begin();
        IDN.insert (Iterate, 10, 'idn');
        for (Iterate = IDN.begin();
                Iterate != IDN.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        IDN.push_back(10);
       
   
    }
                {
        vector<int>::iterator Iterate = test1.begin();
        test1.insert (Iterate, 10, 't1');
        for (Iterate = test1.begin();
                Iterate != test1.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        test1.push_back(10);
       
   
    }
                    {
        vector<int>::iterator Iterate = test2.begin();
        test2.insert (Iterate, 10, 't2');
        for (Iterate = test2.begin();
                Iterate != test2.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        test2.push_back(10);
       
   
    }
    {
        vector<int>::iterator Iterate = test3.begin();
        test3.insert (Iterate, 10, 't3');
        for (Iterate = test3.begin();
                Iterate != test3.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        test3.push_back(10);
       
   
    }
        {
        vector<int>::iterator Iterate = test4.begin();
        test4.insert (Iterate, 10, 't4');
        for (Iterate = test4.begin();
                Iterate != test4.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        test4.push_back(10);
       
   
    }
}


//int Test1, Test2, Test3, Test4;
double avg;
string A, B, C;
for ( j = 0; j <= 9; j++)  // How do I write this part correctly?
{
       
        avg = (test1(10) + test2(10) + test3(10) + test4(10)) / 4;
            
       
    if (89 < avg < 100)
            {              
               
                push_back Grade(A);
           
               
            }
         else
         {
             
             if (79 < avg < 90)                   
            {
             
             Grade[j] = string(B);
             B_counter = B_counter + 1;
            }
         else
            {
             
             Grade[j] = string(C);
             C_counter = C_counter + 1;
            }

         vector<string>::iterator Iterate = grades.begin();
        grades.insert (Iterate, 10, 'grade');
        for (Iterate = grades.begin();
                Iterate != grades.end();
                Iterate ++)
                {
                    cout << *Iterate;
                }
        grades.push_back(10);
}

//total =  total + 1;

}


fout << "Grade" << grades <<endl;

fout << endl;

       
        fout << "Number of A's: " << A_counter << endl;
        fout << "Number of B's: " << B_counter << endl;
        fout << "Number of C's: " << C_counter << endl;
  



inputfile.close();
outputfile.close();
return 0;
}
ifstream inStream;
ofstream outStream;
fout << "Grade" << grades <<endl;
fout << endl;

Here is your problem with fout, you didn't declare an object of the fstream named fout. Now, what other error messages are you getting?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.