#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
	void Set_data()
	{
		cout << "please input the name num and the score of each class:" << endl;
		cout << endl;
		cin >> name >> num >> chin >> math >> eng;
	}
	int Average()
	{
		average = (math + eng + chin) / 3;
		return average;
	}
	void display() {
		cout << "姓名:" << name << endl << "各科成绩" << "chinese:" << " " << chin << "math:" << math << "english:" << eng << endl;
		cout << "average:" << average << endl;
	}

private:
	string name;
	double num;
	double chin;
	double math;
	double eng;
	double average;
};
Student stu1,stu2;
int main()
{
	stu1.Set_data();
	stu1.Average();
	stu1.display();
	cout << "please input the next student's  information " << endl;
	stu2.Set_data();
	stu2.Average();
	stu2.display();



	return 0;
}

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐