用VisualC++6.0设计一个学生成绩管理系统

2024-12-31 17:52:37
推荐回答(1个)
回答1:

// student.h: interface for the student class.
//
//////////////////////////////////////////////////////////////////////

#include "score.h"

//////////////////////////////////////////////////////////////////////
#if !defined(AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_)
#define AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class student
{
public:
student();
virtual ~student();
int getNum();
float sum();
void print();
void modify(char* r,char* n,float m,float e,float c);
private:
char number[20];
char name[30];
score ascore;
};

#endif // !defined(AFX_STUDENT_H__7F838617_8CEB_4640_8740_EA0EFCE6BADE__INCLUDED_)

// student.cpp: implementation of the student class.
//
//////////////////////////////////////////////////////////////////////

#include
#include
#include
#include "student.h"
using namespace std;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

student::student()
{

}

student::~student()
{

}

void student::print()
{
cout<ascore.print();
}
void student::modify(char* r,char* n,float m,float e,float c)
{
strcpy(number,r);
strcpy(name,n);
ascore.modify(m,e,c);
}

float student::sum()
{
float a;// score.h: interface for the score class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_)
#define AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class score
{
public:
score(float c=0.0,float m=0.0,float e=0.0);
virtual ~score();
float sum();
void print();
void modify(float m,float e,float c);
private:
float computer;
float english;
float mathematics;
static float total;
};

#endif // !defined(AFX_SCORE_H__52859404_C529_4188_9FCD_161B7F88FEB3__INCLUDED_)
// score.cpp: implementation of the score class.
//
//////////////////////////////////////////////////////////////////////

#include
#include
#include "score.h"
using namespace std;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

score::score(float c,float m,float e)
{
computer = c;
mathematics = m;
english = e;
total = computer + english +mathematics;
}

score::~score()
{

}

float score::total = 0;

float score::sum()
{
total = mathematics+english+computer;
return total;
}

void score::print()
{
cout<}

void score::modify(float m,float e,float c)
{
mathematics = m;
english = e;
computer = c;
}

#include
#include
#include "score.h"
#include "student.h"
using namespace std;

const int maxSize = 50;

int main()
{
student stu[maxSize];
char number[20];
char name[30];
float tmp_sum;
float math,eng,comp;
int total;

do
{
cout<<"please input the number of students: ";
cin>>total;
if (total>maxSize || total<1)
cout<<"ERROR: 0}
while (total<1 || total>maxSize);

cout<<"please input the student's message:(number name mathematics english computer)"<for (int i=0; i{
cout<<"学生"<cin>>number>>name>>math>>eng>>comp;
stu[i].modify(number,name,math,eng,comp);
}

cout<<"***************************************************"<cout<<for (i=0; i{ tmp_sum = stu[i].sum();
stu[i].print();
cout<}
cout<<"***************************************************"<return 0;
}

/* cin>>reg_num;
bool found = false;
for (i=0; i{
if(stu[i].getNum() == *reg_num)
{
cout<<stu[i].print();
cout<found = true;
break;
}
if (!found)
cout<<"没这个人!"<}
*/

a = ascore.sum();
return a;

}