注册 登录
编程论坛 C++教室

有什么问题啊,为什么没按循环让我输入?

菜鸟想成长 发布于 2016-03-24 13:27, 3205 次点击
#include <iostream>
using namespace std;

class student
{
private:
    char name,pj;
    float ftext,mtext,rtext1,rtext2,allscore;
public:
    void Input();
    void Evaluate();
    void Output();
    student()
    {
        char pj='B';
    }
};

void student::Input()
{
    cout<<"请输入学生的姓名"<<endl;
    cin>>name;
    cout<<"请输入学生两次随堂成绩(0-10),一次期中成绩(0-100)和一次期末成绩(0-100)"<<endl;
    cin>>rtext1>>rtext2>>mtext>>ftext;
}

void student::Evaluate()
{
    allscore=ftext*0.5+mtext*0.25+(rtext1+rtext2)*0.25;
        if(allscore>=90)
            pj='A';
        else if(allscore>=80&&allscore<=89)
            pj='B';
        else if(allscore>=70&&allscore<=79)
            pj='C';
        else if(allscore>=60&&allscore<=69)
            pj='D';
        else
            pj='E';
}

void student::Output()
{
    cout<<"学生姓名:"<<name<<"  随堂成绩1和2"<<rtext1<<rtext2<<endl;
    cout<<"期中成绩和期末成绩:"<<mtext<<ftext<<endl;
}


int main()
{
    student Array[5];
    int i;
    for(i=0;i<5;i++)
    {
        Array[i].Input();
        Array[i].Evaluate();
    }
    for(i=0;i<5;i++)
        Array[i].Output();


    return 0;
}
只有本站会员才能查看附件,请 登录


2 回复
#2
aiyulunhui2016-03-24 13:45
name 类型改为string
#3
菜鸟想成长2016-03-24 14:01
haode
1