student_Class

 avatar
Alexmegawin
c_cpp
2 years ago
2.1 kB
1
Indexable
Never
#include <iostream>
using namespace std;

class student {
private:
	string full_Name;
	int number_Of_Group = 0;
	int marks[5] = { 0, 0, 0, 0, 0 };
public:
	student() {
		cout << "unknown student\n";
	}
	student(string _full_Name, int _number_Of_Group, int _marks[5]) {
		set_Student_Info(_full_Name, _number_Of_Group, _marks);
	}

	void set_Student_Info(string _full_Name, int _number_Of_Group, int _marks[5]) {
		full_Name = _full_Name;
		number_Of_Group = _number_Of_Group;
		for (int i = 0; i < 5; i++) {
			marks[i] = _marks[i];
		}

	}

	void get_Student_Info() {
		cout << "He/She is " << full_Name << ".\nHe/She studied at " << number_Of_Group << " group.\n";

		cout << "His/Her marks: ";
		for (int i = 0; i < 5; i++) {
			cout << marks[i] << " ";
		}
		cout << ".\n";

		float sum = 0;
		for (int i = 0; i < 5; i++) {
			sum += marks[i];
		}
		cout << "GPA is " << sum / 5 << ".";
		cout << "\n\n\n";
	}
	float get_GPA() {
		float sum = 0;
		float GPA[4];
		for (int j = 0; j < 4; j++) {
			for (int i = 0; i < 5; i++) {
				sum += marks[i];
			}
			GPA[j] = sum / 5;
			return GPA[j];
		}
	}
};


int main()
{
	int arr_1[5] = { 5, 5, 5, 4, 5 };
	int arr_2[5] = { 4, 4, 5, 4, 5 };
	int arr_3[5] = { 4, 4, 3, 3, 5 };
	int arr_4[5] = { 3, 4, 3, 2, 3 };

	student student_Info[4] = { student("Rastorguev.A.G", 1, arr_1), student("Rastorguev.A.A", 1, arr_2), student("Rastorguev.A.B", 1, arr_3), student("Rastorguev.B.A", 1, arr_4) };

	/*student student_Info_1 = student("Rastorguev.A.G", 1, arr_1);
	student student_Info_2 = student("Rastorguev.A.A", 1, arr_2);
	student student_Info_3 = student("Rastorguev.A.B", 1, arr_3);
	student student_Info_4 = student("Rastorguev.B.A", 1, arr_4);*/

	student_Info[0].get_Student_Info();
	student_Info[1].get_Student_Info();
	student_Info[2].get_Student_Info();
	student_Info[3].get_Student_Info();

	float max = 0;
	for (int i = 0; i < 4; i++) {
		if (student_Info[i].get_GPA() > max) {
			max = student_Info[i].get_GPA();
		}
	}
	cout << max << endl;

	cout << "highest scoring winner is " << max;
	return 0;
}