路过敲几行,仅供参考
#include
using namespace std;
class Student
{
public:
Student()
{
for(int i=0; i<16; i++)
{
name[i]='\0';
}
level = 'B';
}
void Input()//信息输入
{
cout<<"学生姓名:";
cin>>name;
cout<cin>>score_mid;
cout<cin>>score_fin;
cout<cin>>score_ran1;
cout<cin>>score_ran2;
}
void Evaluate()//成绩计算
{
score = score_fin/100*50 + score_mid/100*25 + score_ran1/10*12.5 + score_ran2/10*12.5;
if(score < 60) level = 'E';
else if(score < 70) level = 'D';
else if(score < 80) level = 'C';
else if(score < 90) level = 'B';
else level = 'A';
}
void Output()//信息输出
{
cout<<"学生信息如下:"<cout<<"姓名:"< cout<<"总成绩:"< cout<<"成绩评级:"< cout<<"期中成绩:"< cout<<"期末成绩:"< cout<<"随堂测试1成绩:"< cout<<"随堂测试2成绩:"< }
int Modify()//成绩修改,修改完自动更新成绩
{
while(1)
{
cout<<"你将修改"<cout<<"1:修改期中成绩"< cout<<"2:修改期末成绩"< cout<<"3:修改随堂测试1成绩"< cout<<"4:修改随堂测试2成绩"< cout<<"0:退出"< cout<<"请输入操作序号:";
int n;
cin>>n;
switch(n)
{
case 0:
Evaluate();
return 0;
break;
case 1:
cout<<"请输入新的期中成绩:" ;
cin>>score_mid;
break;
case 2:
cout<<"请输入新的期末成绩:" ;
cin>>score_fin;
break;
case 3:
cout<<"请输入新的随堂测试1成绩:" ;
cin>>score_ran1;
break;
case 4:
cout<<"请输入新的随堂测试2成绩:" ;
cin>>score_ran2;
break;
defualt:
cout<<"输入有误!"<continue;
break;
}
}
return 1;
}
private:
char name[16];
char level;
float score;
float score_mid;
float score_fin;
float score_ran1;
float score_ran2;
};
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;
}
VS2010写的,有问题再问