Homework_6
Alexmegawin
c_cpp
3 years ago
1.6 kB
8
Indexable
#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"; } }; 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_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_1.get_Student_Info(); student_Info_2.get_Student_Info(); student_Info_3.get_Student_Info(); student_Info_4.get_Student_Info(); cout << "highest scoring winner is Rastorguev.A.G"; return 0; }
Editor is loading...