#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
    string cosid1, cosid2;
    int no_cos=0, nostu1=0, nostu2=0;
    double score, total_1=0, total_2=0, avg_1=0, avg_2=0, avg_group1=0,avg_group2=0;

    ifstream group1, group2;
    ofstream outgroup;

    group1.open ("group1.txt");
    group2.open ("group2.txt");

    if (!group1 || !group2)
    {
        cout<<"Unable file"<<endl;
        cout<<"Programs terminates"<<endl;
    }
    outgroup.open("totalgroup.txt");
    outgroup<<"Course ID"<<'\t'<<"Group No"<<'\t'<<"Course Avg"<<endl;
    outgroup<<"======================================================="<<endl;

    group1>>cosid1;
    group2>>cosid2;
    while (group1 && group2)
    {
        if (cosid1 != cosid2)
        {
            cout<<"Course ID do not match"<<endl;
            cout<<"Program terminates"<<endl;
        }
        else
        {
            group1>>score;
            while (score != -999)
            {
                total_1 += score;
                nostu1++;
                group1>>score;
            }
            avg_1 = total_1/nostu1;

            group2>>score;
            while (score != -999)
            {
                total_2 += score;
                nostu2++;
                group2>>score;
            }
            avg_2 = total_2/nostu2;
        outgroup<<cosid1<<'\t'<<"1"<<'\t'<<avg_1<<endl;
        outgroup<<"    "<<'\t'<<"2"<<'\t'<<avg_2<<endl;
        }
        avg_group1 += avg_1;
        avg_group2 += avg_2;
        no_cos++;

        group1>>cosid1;
        group2>>cosid2;

    }

    outgroup<<"Average for group 1 : "<<avg_group1/no_cos<<endl;
    outgroup<<"Average for group 2 : "<<avg_group2/no_cos<<endl;
    system ("pause");
    return 0;
}

hey guys there is a problem with the input file and there is too many bugs........

hey guys there is a problem with the input file and there is too many bugs........

Wow, that's just soooo informative. Can you elaborate about what the problem is?

Which part is the question?

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.