高手来
c++吧
全部回复
仅看楼主
level 1
沙无尽 楼主
定义一个Student类,包含学号、姓名、语文、数学、外语成绩。 通过setId(int id) 和setName(char *name)函数设置学号和姓名。 通过setScore(float yuwen, float shuxue, float waiyu)方法设置成绩。 通过Calculate()方法计算总分和平均分 通过getSum(), getAverage()取总分和平均分。一个学生的信息保存于一个Student类的实例中
2007年10月13日 05点10分 1
level 0
#include "stdafx.h"#
include "iostream"#include "string"using namespace std;class Student{private: string id; string name; float Chinese; float math; float English; float sum; float average;public: void SetId() { cout<<"Please Input the id:"; cin>>id; } void SetName() { cout<<"Please Input the name:"; cin>>name; } void SetScore() { cout<<"Please Input the Chinese score:"; cin>>Chinese; cout<<"Please Input the math score:"; cin>>math; cout<<"Please Input the English score:"; cin>>English; } void Calculate() { sum=Chinese+math+English; average=sum/3; } float GetSum() { return sum; } float GetAverage() { return average; }};int main(int argc, char* argv[]){ Student I; I.SetId(); I.SetName(); I.SetScore(); I.Calculate(); cout<
2008年01月05日 02点01分 2
level 0
首行可去
2008年01月05日 02点01分 3
1