均值的打印功能未从读取功能获取值

时间:2019-05-24 16:04:03

标签: c++

所以,我几乎要完成我的大学项目,但是我一度陷入困境,无法继续前进。如下面的代码所示,print_MeanAndCheck()无法从read_Marks()获取值。该项目很大,下面的代码只是其中的一部分,而不是完整的项目。因此,如何使该函数从read_Marks()中读取值?

class notes
{
protected:
    int  nr, i;
    string disc[20];
    int note[20];
    string materie;
    double mean=0;

public:
    void read();
    void print();
    void modify();
    double avg();
    int check();
};

class Student : public Name, public Date, public notes
{
public:
    void print_MeanAndCheck();
};

void notes::read()
{
    cout << "Please input the number of school subje : ";
    cin >> nr;
    for (i = 0; i < nr; i++)
    {
        cout << "Introduceti numele disciplinei studiate: ";
        cin >> disc[i];
    }

    for (i = 0; i < nr; i++)
    {
        cout << "Introduceti nota la  " << disc[i] << ":";
        cin >> note[i];
    }
}

double notes::avg()
{
    for (i = 0; i < nr; i++)
        mean += note[i];
    mean /= nr;
    return mean;
}

int notes::check()
{
    int n = 0;
    for (i = 0; i < nr; i++)
    {
        if (note[i] < 5)
            n = n + 1;

    }
    return n;
}

void Student::read_Marks()
{
        notes::read();
}

void Student::print_MeanAndCheck()
{   
    cout << "\nThe mean is: ";
    notes::avg();
    notes::check();
    notes::check();
    if (notes::check() == 1)
        cout << "\nThe student didn`t passed one exam\n";
    if (notes::check() >= 2)
        cout << "\nThe student didn`t passed " << notes::check() << " exams\n";
    if (notes::check() == 0)
        cout << "\nThe students passed all the exams\n";
}

我希望在屏幕上向我显示考试的平均数和失败次数,但实际上它只向我显示消息:(

0 个答案:

没有答案