0% found this document useful (0 votes)
9 views4 pages

Code

The document defines a Student class to store student information like name, code, age, and subject scores. It also defines a StudentManager class to manage a list of students. The main function adds some sample students and prints their information.

Uploaded by

lucifa2892005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Code

The document defines a Student class to store student information like name, code, age, and subject scores. It also defines a StudentManager class to manage a list of students. The main function adds some sample students and prints their information.

Uploaded by

lucifa2892005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Họ tên sinh viên: Đinh Sỹ Minh

Mã sinh viên: 2823230207

Ngày sinh: 13/07/2005

Lớp : TH28.17

#include <iostream>
#include <string>
#include <vector>

using namespace std;

// Khai báo lop hoc sinh


class Student {
private:
string name;
int code;
int age;
double math_score;
double english_score;
double literature_socre;
public:
//Hàm khoi tao
Student(string n, int c, int a, double math, double english, double literature) {
name = n;
age = a;
math_score = math;
english_score = english;
literature_socre = literature;
}

// ham tra ve ten hoc sinh


string get_name() {
return name;
}

// Hàm tra ve tuoi cua hoc sinh


int get_age() {
return age;
}
//ham tra ve diem toan cua hoc sinh
double get_math_score() {
return math_score;
}

// hamtra ve diem tienh anh cua hoc sinh


double get_english_score() {
return english_score;
}

// ham tra ve diem ngu van cua hoc sinh


double get_literature_socre(){
return literature_socre;
}
// ham tra ve diem trung binh cua hoc sinh
double get_average_score() {
return (math_score + english_score + literature_socre) / 3.0;
}

// ham in thong tin hoc sinh ra man hinh


void print_info() {
cout << "Thong tin cua hoc sinh:" << endl;
cout << "ma sinh vien:" << code << endl;
cout << "Ten: " << name << endl;
cout << "Tuoi: " << age << endl;
cout << "Diem Toan: " << math_score << endl;
cout << "Diem Tieng Anh: " << english_score << endl;
cout << "Diem Ngu Van:"<<literature_socre << endl;
cout << "Diem Trung Binh: " << get_average_score() << endl;
}
};

// khai bao lop quan li hoc sinh


class StudentManager {
private:
vector<Student> students;
public:
// ham them hoc sinh moi
void add_student(Student student) {
students.push_back(student);
}
// Hàm in danh sach hoc sinh ra man hinh
void print_students() {
for (int i = 0; i < students.size(); i++) {
students[i].print_info();
cout << endl;
}
}
};

int main() {
// tao doi tuong quan li hoc sinh
StudentManager manager;

// Them hoc sinh vao danh sach


manager.add_student(Student("Nguyen Van A", 11, 18, 8.5, 9.0, 7.0));
manager.add_student(Student("Tran Thi B", 12, 19, 7.5, 8.0, 6.0));
manager.add_student(Student("Pham Van C", 24, 17, 7.5, 8.0, 7.0));

// In danh sach hoc sinh ra man hinh


manager.print_students();

return 0;
}

You might also like