By GokiSoft.com| 16:02 19/09/2022|
Java Basic

Java Basic- OOP - Tổng hợp - Quản lý sinh viên - giáo viên bằng java

Câu 1:

Tạo lớp Person chứa thông tin

- Tên

- Giới tính

- Ngày sinh

- Địa chỉ

Với đầy đủ hàm get set, constructor không tham số, constructor đầy đủ tham số

1. Viết phương thức inputInfo(), nhập thông tin Person từ bàn phím

2. Viết phương thức showInfo(), hiển thị tất cả thông tin Person

Câu 2:

Tạo lớp Student thừa kế Person, lưu trữ các thông tin một sinh viên

- Mã sinh viên: chứa 8 kí tự

- Điểm trung bình: từ 0.0 – 10.0

- Email: phải chứa kí tự @ và không tồn tại khoảng trắng

1. Override phương thức inputInfo(), nhập thông tin Student từ bàn phím

2. Override phương thức showInfo(), hiển thị tất cả thông tin Student

3. Viết phương thức xét xem Student có được học bổng không? Điểm trung bình trên 8.0 là được học bổng

Câu 3:

Tạo lớp StudentTest, chứa Main kiểm tra chức năng lớp Student

Tạo Menu chọn như sau

a. Chọn 1: Nhập vào n sinh viên (n là số lượng sinh viên, được nhập từ bàn phím)

b. Chọn 2: Hiển thị thông tin tất cả các sinh viên ra màn hình

c. Chọn 3: Hiển thị sinh viên có điểm trung bình cao nhất và sinh viên có điểm trung bình thấp nhất

d. Chọn 4: Tìm kiếm sinh viên theo mã sinh viên. Nhập vào mã sinh viên. Nếu tồn tại sinh viên

có mã đó thì in ra màn hình thông tin sinh viên. Nếu không tồn tại thì in ra: Không có sinh

viên nào có mã là <giá trị của mã sinh viên>

e. Chọn 5: Hiển thị tất cả các sinh viên theo thứ tự tên trong bảng chữ cái (A->Z)

f. Chọn 6: Hiển thị tất cả các sinh viên được học bổng, và sắp xếp theo thứ tự điểm cao xuống thấp

g. Chọn 7: Thoát

Câu 4:

Tạo lớp Teacher, kế thừa từ Person, lưu trữ thông tin một giảng viên

- Lớp dạy: Lưu lớp mà giảng viên dạy giống như aptech (ví dụ C1011L, C0903H, C1010KV…)

- Lương một giờ dạy

- Số giờ dạy trong tháng

1. Override phương thức inputInfo(), nhập thông tin Teacher từ bàn phím

2. Override phương thức showInfo(), hiển thị tất cả thông tin Teacher

3. Viết phương thức tính lương thực nhận, trả về lương thực nhận theo công thức:

Nếu lớp dạy là lớp buổi sáng và chiều (Giờ G, H, I, K) thì

Lương thực nhận = lương một giờ dạy * số giờ dạy trong tháng;

Nếu lớp dạy là lớp buổi tối (Giờ L, giờ M) thì

Lương thực nhân = lương một giờ dạy * số giờ dạy trong tháng + 200000đ;

Câu 5:

Tạo lớp TeacherTest, chứa hàm Main kiểm tra chức năng của Teacher

Tạo menu lựa chọn như sau:

a. Chọn 1: Nhập vào n giảng viên (n là số lượng sinh viên, được nhập từ bàn phím)

b. Chọn 2: Hiển thị thông tin tất cả các giảng viên ra màn hình

c. Chọn 3: Hiển thị giảng viên có lương cao nhất

d. Chọn 4: Thoát

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

đỗ đình vang [JavaFree]
đỗ đình vang

2020-05-02 03:49:57



import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}













import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}








import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}













import java.util.ArrayList;

public class Student extends Person {
		public Student() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Student(String name, String gender, String birthday, String address) {
		super(name, gender, birthday, address);
		// TODO Auto-generated constructor stub
	}
		public Student(String msv, double gPA, String email) {
		super();
		this.msv = msv;
		GPA = gPA;
		this.email = email;
	}
		String msv;
		double GPA;
		String email;
		public String getMsv() {
			return msv;
		}
		public void setMsv(String msv) {
			this.msv = msv;
		}
		public double getGPA() {
			return GPA;
		}
		public void setGPA(double gPA) {
			GPA = gPA;
		}
		public String getEmail() {
			return email;
		}
		public void setEmail(String email) {
			this.email = email;
		}
		//nhap thong tin
		public void inputInfo() {
			super.inputInfo();
			System.out.println(" nhap ma sinh vien");
			 msv=sc.nextLine();
			while(msv.length()!=8&&!msv.contains(" ")) {
				System.err.println(" vui long nhap lai(msv phai du 8 ki tu va khong chua khoang trang)");
				msv=sc.nextLine();
			}
			System.out.println(" nhap diem trung binh(GPA)");
			GPA=Double.parseDouble(sc.nextLine());
			while(GPA>10.0||GPA<0.0) {
				System.err.println(" vui long nhap lai(diem trung binh phai thuoc trong khoang 0.0 – 10.0");
				GPA=Double.parseDouble(sc.nextLine());
			}
			System.out.println(" nhap email");
			email=sc.nextLine();
			while(!email.contains("@")||email.contains(" ")) {
				System.err.println(" vui long nhap lai(email nhap vao phai chua ki tu @ va khong chua khaong trang)");
				email=sc.nextLine();
			}
			
		}
		// hien thi thong tin sinh vien
		public void showInfo() {
			System.out.println(toString());
			
		}
		// kiem tra sinh vien co duoc hoc bong
		public boolean check(ArrayList<Student> student,int count) {
					if(student.get(count).getGPA()>=8.0) {
						return true;
					}
				
				return false;
		}
		
		
		@Override
		public String toString() {
			return super.toString()+" msv=" + msv + ", GPA=" + GPA + ", email=" + email ;
		}
}














import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class StudentTest {
public static  Scanner scan =new Scanner(System.in);
	public static void main(String[] args) {
		ArrayList<Student>student=new ArrayList<>();
		Student student2=new Student();
		int n;
		// TODO Auto-generated method stub
		do {
			showMenu();
			System.out.println(" nhap chuc nang");
			n=Integer.parseInt(scan.nextLine());
			switch(n) {
			case 1:
				System.out.println(" nhap so sinh vien can them");
				int m=Integer.parseInt(scan.nextLine());
				for(int i=0; i<m; i++) {
					Student student1= new Student();
					student1.inputInfo();
					student.add(student1);
				}
				break;
			case 2:
				System.out.println("Danh sach thong tin sinh vien");
				for(int i=0; i<student.size(); i++) {
					student.get(i).showInfo();
				}
				break;
			case 3:
				search(student);
				break;
			case 4:
				System.out.println(" thong tin sinh vien ban can tim: ");
				search1(student);
				break;
			case 5:
				System.out.println(" danh sac thong tin sinh vien theo bang chu cai");
				outPut(student);
				break;
			case 6:
				int count=0;
				ArrayList<Student>studenttwo= new ArrayList<>();/* mang danh sach sinh vien
				duoc hoc bong*/
				System.out.println("  Danh Thong tin sinh vien duoc hoc bong");
				for(int i=0; i<student.size();i++) {
					if(student2.check(student, i)) {
						count++;
						studenttwo.add(student.get(i));
					}
				}
				if(count==0) {
					System.err.println(" Khong co sinh vien nao duoc hoc bong");
				}
				
				Collections.sort(studenttwo, new Comparator<Student>() {
					public int compare(Student o1, Student o2) {
						if(o1.getGPA()<o2.getGPA()) {
							return 1;
						}
						else {
							return -1;
						}
					}
					
				});
				for(int i=0; i<studenttwo.size(); i++) {
					studenttwo.get(i).showInfo();
					
				}
				
				 break;
			case 7:
				System.out.println(" Exit!!");
				break;
				default:
					System.err.println(" hay nhap lai");
			}
			
			
		}while(n!=7);

	}
	//Danh sach chon
	public static void  showMenu() {
		System.out.println("1.Them sinh vien");
		System.out.println("2.Hien thi thong tin tat ca sinh vien");
		System.out.println("3.hien thi sinh vien co diem trung binh ca nhat "
				+ "va sinh vien co diem trung binh thap nhat");
		System.out.println("4.Tim kiem sinh vien theo ma sinh vien");
		System.out.println("5.Hien thi thong tin sinh vien theo bang chu cai");
		System.out.println("6.Hien thi sinh vien duoc hoc bong va"
				+ "sap xep tu cao xuong thap");
		System.out.println("7.Thoat chuong trinh");
	}
	// tim sinh vien co diem GPA cao nhat va thap nhat
	public static void search(ArrayList<Student> studentone) {
				double temp=0.0;
				double GPAmax,GPAmin;
				// tim kiem sinh vien co GPA cao nhat
				for(int i=0; i< studentone.size(); i++) {
					if(studentone.get(i).getGPA()>temp) {
						temp=studentone.get(i).getGPA();
					}
				}
				GPAmax=temp;
				for(int i=0; i<studentone.size(); i++) {
					if(studentone.get(i).getGPA()==GPAmax) {
						studentone.get(i).showInfo();
					}
				}
				// tim kiem sinh vien co GPA thap nhat
				for(int i=0; i< studentone.size(); i++) {
					if(studentone.get(i).getGPA()<temp) {
						temp=studentone.get(i).getGPA();
					}
				}
				GPAmin=temp;
				for(int i=0; i<studentone.size(); i++) {
					if(studentone.get(i).getGPA()==GPAmin) {
						studentone.get(i).showInfo();
					}
				}
			}
	// tim kiem sinh vien theo ma sinh vien
	public static void search1(ArrayList<Student> studentone) {
		System.out.println(" nhap ma sinh vien can tim");
		String msv=scan.nextLine();
		for(int i=0; i<studentone.size(); i++) {
			if(studentone.get(i).getMsv().equalsIgnoreCase(msv)) {
				studentone.get(i).showInfo();
			}
		}
	}
		// hien thi thong sinh vien thao bang chu cai
	public static void outPut(ArrayList<Student>studentone) {
		Collections.sort(studentone, new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {
				if(o1.getName().compareToIgnoreCase(o2.getName())>0) {
					return 1;
				}
				else {
					return -1;
				}
			}
		});
		for(int i=0; i<studentone.size(); i++) {
			studentone.get(i).showInfo();
		}
	}
	

}












import java.util.ArrayList;

public class Teacher extends Person{
	String classes;
	double salary;
	int hours;
	double pay;
	public Teacher(String classes, double salary, int hours) {
		super();
		this.classes = classes;
		this.salary = salary;
		this.hours = hours;
	}
	public Teacher() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getClasses() {
		return classes;
	}
	public void setClasses(String classes) {
		this.classes = classes;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	public int getHours() {
		return hours;
	}
	public void setHours(int hours) {
		this.hours = hours;
	}
	public Double getPay() {
		return pay;
	}
	public void setClasses(Double pay) {
		this.pay = pay;
	}
	// nhap thong tim giao vien
	public void inputInfo() {
		super.inputInfo();
		System.out.println(" lop day");
		classes=sc.nextLine();
		System.out.println(" luong 1 gio day");
		salary=Double.parseDouble(sc.nextLine());
		System.out.println("so gio dau trong 1 thang");
		hours=Integer.parseInt(sc.nextLine());
	}
	public void showInfo() {
		System.out.println(toString());
		
	}
	public String toString() {
		return super.toString()+ " Lop day="+classes+",luong 1 gio day="+salary+
				",so gio day trong 1 thang= "+hours+",Luong duoc tra= "+pay;
	}
	//  tinh luong
	public double pay(ArrayList<Teacher>teacher, int count) {
		if(teacher.get(count).getClasses().contains("s")||getClasses().contains("ch") ) {
			pay=salary*hours;
			return pay;
		}
		if(teacher.get(count).getClasses().contains("t")) {
			pay=salary*hours+200000;
			return pay;
		}
		return 0;
	}
}












import java.util.ArrayList;
import java.util.Scanner;

public class TeacherTest {
	public static void main(String []agrs) {
		Teacher teacherone=new Teacher();
		Scanner scan=new Scanner(System.in);
		ArrayList<Teacher>teacher= new ArrayList<>();
		int n;
		do {
			System.out.println(" chon chuc nang");
			showMenu();
			 n=Integer.parseInt(scan.nextLine());
			 switch(n) {
			 case 1:
				 System.out.println(" Nhap so giang  vien");
				 int gv=Integer.parseInt(scan.nextLine());
				 for(int i=0; i<gv; i++) {
					 teacherone.inputInfo();
					 teacher.add(teacherone);
					 teacherone.pay(teacher, i);
				 }
				 break;
			 case 2:
				 System.out.println(" danh sach thong tin giang vien");
				for (int i = 0; i < teacher.size(); i++) {
					teacher.get(i).showInfo();
				}
				 break;
			 case 3:
				 System.out.println(" Thong tin giang vien co luong cao nhat");
				 double temp=0;
				 for(int i=0; i<teacher.size();i++) {
					 if(teacher.get(i).getPay()>temp) {
						 temp=teacher.get(i).getPay();
					 }
				 }
				 for (Teacher teacher2 : teacher) {
					 if(teacher2.getPay()==temp) {
						 teacher2.showInfo();
					 }
				}
				 break;
			 case 4:
				 System.out.println("Exit!!!");
				 break;
				 default:
					 System.err.println(" vui long nhap lai");
			 }
			
		}while(n!=4);
		
	}
	public static void showMenu() {
		System.out.println("1.Nhap so giang vien");
		System.out.println("2.Hien thi thong tin tat ca cac giang vien");
		System.out.println("3.Hien thi thong tin giang vien co luong cao nhat");
		System.out.println("4.Thoat chuong trinh");
	}

}








đỗ đình vang [JavaFree]
đỗ đình vang

2020-05-02 03:49:06



import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}













import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}








import java.util.Scanner;

public class Person {
	public Scanner sc =new Scanner(System.in);
	public Person() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Person(String name, String gender, String birthday, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthday = birthday;
		this.address = address;
	}
	String name;
	String gender;
	String birthday;
	String address;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	@Override
	public String toString() {
		return "Thongtin:name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + ",";
	}
	//nhapthongtin
	public void inputInfo() {
		System.out.println(" nhap ten");
		name=sc.nextLine();
		System.out.println(" nhap gioi tinh ");
		gender=sc.nextLine();
		System.out.println(" nhap ngay sinh");
		birthday=sc.nextLine();
		System.out.println(" nhap dia chi");
		address =sc.nextLine();
	}
	//hien thi thong tin
	public void showInfo() {
		System.out.println(toString());
	}
}













import java.util.ArrayList;

public class Student extends Person {
		public Student() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Student(String name, String gender, String birthday, String address) {
		super(name, gender, birthday, address);
		// TODO Auto-generated constructor stub
	}
		public Student(String msv, double gPA, String email) {
		super();
		this.msv = msv;
		GPA = gPA;
		this.email = email;
	}
		String msv;
		double GPA;
		String email;
		public String getMsv() {
			return msv;
		}
		public void setMsv(String msv) {
			this.msv = msv;
		}
		public double getGPA() {
			return GPA;
		}
		public void setGPA(double gPA) {
			GPA = gPA;
		}
		public String getEmail() {
			return email;
		}
		public void setEmail(String email) {
			this.email = email;
		}
		//nhap thong tin
		public void inputInfo() {
			super.inputInfo();
			System.out.println(" nhap ma sinh vien");
			 msv=sc.nextLine();
			while(msv.length()!=8&&!msv.contains(" ")) {
				System.err.println(" vui long nhap lai(msv phai du 8 ki tu va khong chua khoang trang)");
				msv=sc.nextLine();
			}
			System.out.println(" nhap diem trung binh(GPA)");
			GPA=Double.parseDouble(sc.nextLine());
			while(GPA>10.0||GPA<0.0) {
				System.err.println(" vui long nhap lai(diem trung binh phai thuoc trong khoang 0.0 – 10.0");
				GPA=Double.parseDouble(sc.nextLine());
			}
			System.out.println(" nhap email");
			email=sc.nextLine();
			while(!email.contains("@")||email.contains(" ")) {
				System.err.println(" vui long nhap lai(email nhap vao phai chua ki tu @ va khong chua khaong trang)");
				email=sc.nextLine();
			}
			
		}
		// hien thi thong tin sinh vien
		public void showInfo() {
			System.out.println(toString());
			
		}
		// kiem tra sinh vien co duoc hoc bong
		public boolean check(ArrayList<Student> student,int count) {
					if(student.get(count).getGPA()>=8.0) {
						return true;
					}
				
				return false;
		}
		
		
		@Override
		public String toString() {
			return super.toString()+" msv=" + msv + ", GPA=" + GPA + ", email=" + email ;
		}
}














import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class StudentTest {
public static  Scanner scan =new Scanner(System.in);
	public static void main(String[] args) {
		ArrayList<Student>student=new ArrayList<>();
		Student student2=new Student();
		int n;
		// TODO Auto-generated method stub
		do {
			showMenu();
			System.out.println(" nhap chuc nang");
			n=Integer.parseInt(scan.nextLine());
			switch(n) {
			case 1:
				System.out.println(" nhap so sinh vien can them");
				int m=Integer.parseInt(scan.nextLine());
				for(int i=0; i<m; i++) {
					Student student1= new Student();
					student1.inputInfo();
					student.add(student1);
				}
				break;
			case 2:
				System.out.println("Danh sach thong tin sinh vien");
				for(int i=0; i<student.size(); i++) {
					student.get(i).showInfo();
				}
				break;
			case 3:
				search(student);
				break;
			case 4:
				System.out.println(" thong tin sinh vien ban can tim: ");
				search1(student);
				break;
			case 5:
				System.out.println(" danh sac thong tin sinh vien theo bang chu cai");
				outPut(student);
				break;
			case 6:
				int count=0;
				ArrayList<Student>studenttwo= new ArrayList<>();/* mang danh sach sinh vien
				duoc hoc bong*/
				System.out.println("  Danh Thong tin sinh vien duoc hoc bong");
				for(int i=0; i<student.size();i++) {
					if(student2.check(student, i)) {
						count++;
						studenttwo.add(student.get(i));
					}
				}
				if(count==0) {
					System.err.println(" Khong co sinh vien nao duoc hoc bong");
				}
				
				Collections.sort(studenttwo, new Comparator<Student>() {
					public int compare(Student o1, Student o2) {
						if(o1.getGPA()<o2.getGPA()) {
							return 1;
						}
						else {
							return -1;
						}
					}
					
				});
				for(int i=0; i<studenttwo.size(); i++) {
					studenttwo.get(i).showInfo();
					
				}
				
				 break;
			case 7:
				System.out.println(" Exit!!");
				break;
				default:
					System.err.println(" hay nhap lai");
			}
			
			
		}while(n!=7);

	}
	//Danh sach chon
	public static void  showMenu() {
		System.out.println("1.Them sinh vien");
		System.out.println("2.Hien thi thong tin tat ca sinh vien");
		System.out.println("3.hien thi sinh vien co diem trung binh ca nhat "
				+ "va sinh vien co diem trung binh thap nhat");
		System.out.println("4.Tim kiem sinh vien theo ma sinh vien");
		System.out.println("5.Hien thi thong tin sinh vien theo bang chu cai");
		System.out.println("6.Hien thi sinh vien duoc hoc bong va"
				+ "sap xep tu cao xuong thap");
		System.out.println("7.Thoat chuong trinh");
	}
	// tim sinh vien co diem GPA cao nhat va thap nhat
	public static void search(ArrayList<Student> studentone) {
				double temp=0.0;
				double GPAmax,GPAmin;
				// tim kiem sinh vien co GPA cao nhat
				for(int i=0; i< studentone.size(); i++) {
					if(studentone.get(i).getGPA()>temp) {
						temp=studentone.get(i).getGPA();
					}
				}
				GPAmax=temp;
				for(int i=0; i<studentone.size(); i++) {
					if(studentone.get(i).getGPA()==GPAmax) {
						studentone.get(i).showInfo();
					}
				}
				// tim kiem sinh vien co GPA thap nhat
				for(int i=0; i< studentone.size(); i++) {
					if(studentone.get(i).getGPA()<temp) {
						temp=studentone.get(i).getGPA();
					}
				}
				GPAmin=temp;
				for(int i=0; i<studentone.size(); i++) {
					if(studentone.get(i).getGPA()==GPAmin) {
						studentone.get(i).showInfo();
					}
				}
			}
	// tim kiem sinh vien theo ma sinh vien
	public static void search1(ArrayList<Student> studentone) {
		System.out.println(" nhap ma sinh vien can tim");
		String msv=scan.nextLine();
		for(int i=0; i<studentone.size(); i++) {
			if(studentone.get(i).getMsv().equalsIgnoreCase(msv)) {
				studentone.get(i).showInfo();
			}
		}
	}
		// hien thi thong sinh vien thao bang chu cai
	public static void outPut(ArrayList<Student>studentone) {
		Collections.sort(studentone, new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {
				if(o1.getName().compareToIgnoreCase(o2.getName())>0) {
					return 1;
				}
				else {
					return -1;
				}
			}
		});
		for(int i=0; i<studentone.size(); i++) {
			studentone.get(i).showInfo();
		}
	}
	

}












import java.util.ArrayList;

public class Teacher extends Person{
	String classes;
	double salary;
	int hours;
	double pay;
	public Teacher(String classes, double salary, int hours) {
		super();
		this.classes = classes;
		this.salary = salary;
		this.hours = hours;
	}
	public Teacher() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getClasses() {
		return classes;
	}
	public void setClasses(String classes) {
		this.classes = classes;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	public int getHours() {
		return hours;
	}
	public void setHours(int hours) {
		this.hours = hours;
	}
	public Double getPay() {
		return pay;
	}
	public void setClasses(Double pay) {
		this.pay = pay;
	}
	// nhap thong tim giao vien
	public void inputInfo() {
		super.inputInfo();
		System.out.println(" lop day");
		classes=sc.nextLine();
		System.out.println(" luong 1 gio day");
		salary=Double.parseDouble(sc.nextLine());
		System.out.println("so gio dau trong 1 thang");
		hours=Integer.parseInt(sc.nextLine());
	}
	public void showInfo() {
		System.out.println(toString());
		
	}
	public String toString() {
		return super.toString()+ " Lop day="+classes+",luong 1 gio day="+salary+
				",so gio day trong 1 thang= "+hours+",Luong duoc tra= "+pay;
	}
	//  tinh luong
	public double pay(ArrayList<Teacher>teacher, int count) {
		if(teacher.get(count).getClasses().contains("s")||getClasses().contains("ch") ) {
			pay=salary*hours;
			return pay;
		}
		if(teacher.get(count).getClasses().contains("t")) {
			pay=salary*hours+200000;
			return pay;
		}
		return 0;
	}
}












import java.util.ArrayList;
import java.util.Scanner;

public class TeacherTest {
	public static void main(String []agrs) {
		Teacher teacherone=new Teacher();
		Scanner scan=new Scanner(System.in);
		ArrayList<Teacher>teacher= new ArrayList<>();
		int n;
		do {
			System.out.println(" chon chuc nang");
			showMenu();
			 n=Integer.parseInt(scan.nextLine());
			 switch(n) {
			 case 1:
				 System.out.println(" Nhap so giang  vien");
				 int gv=Integer.parseInt(scan.nextLine());
				 for(int i=0; i<gv; i++) {
					 teacherone.inputInfo();
					 teacher.add(teacherone);
					 teacherone.pay(teacher, i);
				 }
				 break;
			 case 2:
				 System.out.println(" danh sach thong tin giang vien");
				for (int i = 0; i < teacher.size(); i++) {
					teacher.get(i).showInfo();
				}
				 break;
			 case 3:
				 System.out.println(" Thong tin giang vien co luong cao nhat");
				 double temp=0;
				 for(int i=0; i<teacher.size();i++) {
					 if(teacher.get(i).getPay()>temp) {
						 temp=teacher.get(i).getPay();
					 }
				 }
				 for (Teacher teacher2 : teacher) {
					 if(teacher2.getPay()==temp) {
						 teacher2.showInfo();
					 }
				}
				 break;
			 case 4:
				 System.out.println("Exit!!!");
				 break;
				 default:
					 System.err.println(" vui long nhap lai");
			 }
			
		}while(n!=4);
		
	}
	public static void showMenu() {
		System.out.println("1.Nhap so giang vien");
		System.out.println("2.Hien thi thong tin tat ca cac giang vien");
		System.out.println("3.Hien thi thong tin giang vien co luong cao nhat");
		System.out.println("4.Thoat chuong trinh");
	}

}








Phạm Kim Anh [JavaFree]
Phạm Kim Anh

2020-03-25 16:44:48



package quanlysinhvien_giaovien;

import java.util.Scanner;

public class Person {

	private String name;
	private String gender;
	private String dateOfBirth;
	private String address;
	
	final static Scanner sc = new Scanner(System.in);
	public Person() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param name
	 * @param gender
	 * @param dateOfBirth
	 * @param address
	 */
	public Person(String name, String gender, String dateOfBirth, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.dateOfBirth = dateOfBirth;
		this.address = address;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(String dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	public void inputInfo() {
		System.out.println("Moi ban nhap ten: ");
		name = sc.nextLine();
		
		System.out.println("Moi ban nhap gioi tinh: ");
		gender = sc.nextLine();
		
		System.out.println("Moi ban nhap ngay sinh: ");
		dateOfBirth = sc.nextLine();
		
		System.out.println("Moi ban nhap dia chi: ");
		address = sc.nextLine();
	}
	
	public void showInfo() {
		System.out.println("------------------------------");
		System.out.println("Ten : "+name);
		System.out.println("Gioi tinh: "+gender);
		System.out.println("Ngay sinh: "+dateOfBirth);
		System.out.println("Dia chi: "+address);
	}
}

package quanlysinhvien_giaovien;

public class Student extends Person{

	private String id;
	private float mark;
	private String email;
	
	public Student() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param id
	 * @param mark
	 * @param email
	 */
	public Student(String id, float mark, String email) {
		super();
		this.id = id;
		this.mark = mark;
		this.email = email;
	}

	public String getId() {
		return id;
	}

	public boolean setId(String id) {
		if(id != null && id.length()==8) {
			this.id = id;
			return true;
		} else {
			System.err.println("Moi ban nhap lai ma sinh vien (do dai = 8 ki tu): ");
			return false;
		}
		
	}

	public float getMark() {
		return mark;
	}

	public boolean setMark(float mark) {
		if(mark >= 0 && mark <= 10) {
			this.mark = mark;
			return true;
		} else {
			System.err.println("Moi ban nhap lai diem(diem >= 0 && diem <= 10): ");
			return false;
		}
		
	}

	public String getEmail() {
		return email;
	}

	public boolean setEmail(String email) {
		if(email != null && !email.contains("") && email.contains("@")) {
			this.email = email;
			return true;
		} else {
			System.err.println("Moi ban nhap lai email(email khong de trong, khong chua khoang trang va chua dau @): ");
			return false;
		}
		
	}
	
	@Override
	public void inputInfo() {
		super.inputInfo();
		
		System.out.println("Moi ban nhap ma sinh vien: ");
		while(true) {
			String masv = sc.nextLine();
			boolean check = setId(masv);
			if (check) {
				break;
			}
		}
		
		System.out.println("Moi ban nhap diem trung binh: ");
		while(true) {
			float diemTB = Float.parseFloat(sc.nextLine());
			boolean check = setMark(diemTB);
			if(check) {
				break;
			}
		}
		
		System.out.println("Moi ban nhap email: ");
		while(true) {
			String email = sc.nextLine();
			boolean check = setEmail(email);
			if(check) {
				break;
			}
		}
	}
	
	@Override
	public void showInfo() {
		super.showInfo();
		System.out.println("Ma sinh vien: "+id);
		System.out.println("Diem trung binh: "+mark);
		System.out.println("Email: "+email);
		System.out.println();
	}
	
	public boolean checkScholarship() {
		if(mark > 8.0) {
			return true;
		}
		return false;
	}
}

package quanlysinhvien_giaovien;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class StudentTest {

	public static void main(String[] args) {
		 
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Student> listStd = new ArrayList<Student>();

		int choose;
		boolean exit = false;
		int i;
		do {
			Menu();
			System.out.println("Moi ban nhap lua chon: ");
			choose = Integer.parseInt(sc.nextLine());
			switch(choose) {
			
			case 1:
				System.out.println("1. Nhap vao n sinh vien");
				
				System.out.println("Moi ban nhap so sinh vien can them: ");
				int n = Integer.parseInt(sc.nextLine());
				for(i = 0; i <n; i++) {
					Student st = new Student();
					st.inputInfo();
					listStd.add(st);
				}
				break;
			
			case 2:
				System.out.println("2. Hien thi tat ca cac sinh vien ra man hinh");
				
				for( i = 0; i < listStd.size(); i++) {
					listStd.get(i).showInfo();
				}
				break;
			
			case 3:
				System.out.println("3. Hien thi sinh vien co diem trung binh cao nhat \n va sinh vien co diem trung binh thap nhat");
				
				int minIndex = 0, maxIndex = 0;
				float minMark, maxMark;
				
				minMark = listStd.get(0).getMark();
				maxMark = listStd.get(0).getMark();
				
				for( i = 1; i < listStd.size(); i++) {
					if(listStd.get(i).getMark() < minMark) {
						minIndex = i;
						minMark = listStd.get(i).getMark();
					}
					if(listStd.get(i).getMark() > maxMark) {
						maxIndex = i;
						maxMark = listStd.get(i).getMark();
					}
				}
				
				System.out.println("Sinh vien co diem cao nhat la: ");
				listStd.get(maxIndex).showInfo();
				
				System.out.println("Sinh vien co diem thap nhat la: ");
				listStd.get(minIndex).showInfo();
				break;
			
			case 4:
				System.out.println("4. Tim kiem sinh vien theo ma sinh vien");
				
				System.out.println("Moi ban nhap ma sinh vien can tim: ");
				String id = sc.nextLine();
				int dem = 0;
				
				for(Student st : listStd) {
					if (st.getId().equalsIgnoreCase(id)) {
						st.showInfo();
						dem++;
					}
				}
				if(dem == 0) {
					System.out.println("Khong tim thay sinh vien nao co id = "+id);
				}
				break;
			
			case 5:
				System.out.println("5. Hiem thi tat ca cac sinh vien theo thu tu ten trong bang chu cai");
				
				Collections.sort(listStd, new Comparator<Student>() {

					@Override
					public int compare(Student o1, Student o2) {
						int cmp = o1.getName().compareTo(o2.getName());
						if(cmp >= 0) {
							return 1;
						}
						return -1;
					}
				});
				
				for( i = 0; i < listStd.size(); i++) {
					listStd.get(i).showInfo();
				}
				break;
			
			case 6:
				System.out.println("6. Hien thi tat ca cac sinh vien duoc hoc bong \n va sap xep theo thu tu diem cao xuong thap ");
				
				Collections.sort(listStd, new Comparator<Student>() {

					@Override
					public int compare(Student o1, Student o2) {
						return o1.getMark() >= o2.getMark() ? -1:1;
					}
				});
				
				for(i = 0; i <listStd.size(); i++) {
					if(listStd.get(i).checkScholarship()) {
						listStd.get(i).showInfo();
					}
				}
				break;
			
			case 7:
				System.out.println("goodbye!");
				exit = true;
				break;
			
			default:
				System.err.println("Nhap sai! Moi ban nhap lai lua chon");
				break;
			}
		} while(choose != 7);
	}
	
	static void Menu() {
		System.out.println("=========================================================================");
		System.out.println("1. Nhap vao n sinh vien");
		System.out.println("2. Hien thi thong tin tat ca sinh vien ra man hinh");
		System.out.println("3. Hien thi sinh vien co diem trung binh cao nhat \n va sinh vien co diem trung binh thap nhat");
		System.out.println("4. Tim kiem sinh vien theo ma sinh vien");
		System.out.println("5. Hien thi tat ca cac sinh vien theo thu tu ten trong bang chu cai");
		System.out.println("6. Hien thi tat ca cac sinh vien duoc hoc bong \n va sap xep theo thu tu diem cao xuong thap ");
		System.out.println("7. Thoat");
		System.out.println("=========================================================================");
	}
}


package quanlysinhvien_giaovien;

public class Teacher extends Person{

	//Lop day : vd C1011L
	private String teachingClass;
	//luong 1 gio day
	private float salary;
	//so gio day trong thang
	private float hour;
	
	public Teacher() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param teachingClass
	 * @param salary
	 * @param hour
	 */
	public Teacher(String teachingClass, float salary, float hour) {
		super();
		this.teachingClass = teachingClass;
		this.salary = salary;
		this.hour = hour;
	}

	public String getTeachingClass() {
		return teachingClass;
	}

	public void setTeachingClass(String teachingClass) {
		this.teachingClass = teachingClass;
	}

	public float getSalary() {
		return salary;
	}

	public void setSalary(float salary) {
		this.salary = salary;
	}

	public float getHour() {
		return hour;
	}

	public void setHour(float hour) {
		this.hour = hour;
	}
	
	@Override
	public void inputInfo() {
		super.inputInfo();
		System.out.println("Moi ban nhap lop day: ");
		teachingClass = sc.nextLine();
		System.out.println("Moi ban nhap luong mot gio day: ");
		salary = Float.parseFloat(sc.nextLine());
		System.out.println("Moi ban nhap so gio day trong thang: ");
		hour = Float.parseFloat(sc.nextLine());
	}
	
	@Override
	public void showInfo() {
		super.showInfo();
		System.out.println("Lop day: "+teachingClass);
		System.out.println("Luong mot gio day: "+salary);
		System.out.println("So gio day trong thang: "+hour);
	}
	
	public double tinhLuong() {
		double luong = salary * hour;
		char c = teachingClass.charAt(5);
		if(Character.toString(c).equals("M") || Character.toString(c).equals("L")) {
			luong = luong + 200000;
		}
		return luong;
	}
}

package quanlysinhvien_giaovien;

import java.util.ArrayList;
import java.util.Scanner;

public class TeacherTest {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Teacher> listTeachers = new ArrayList<Teacher>();
		
		int choose;
		boolean exit = false;
		int i;
		do {
			menu();
			System.out.println("Moi ban nhap lua chon: ");
			choose = Integer.parseInt(sc.nextLine());
			switch(choose) {
			case 1:
				System.out.println("1. Nhap vao n giang vien");
				
				System.out.println("Moi ban nhap so giang vien muon them: ");
				int n = Integer.parseInt(sc.nextLine());
				
				for(i = 0; i < n; i++) {
					Teacher teacher = new Teacher();
					teacher.inputInfo();
					listTeachers.add(teacher);
				}
				break;
			case 2:
				System.out.println("2. Hien thi thong tin tat ca cac giang vien ");
				for(Teacher t : listTeachers) {
					t.showInfo();
				}
				break;
			case 3:
				System.out.println("3. Hien thi giang vien co luong cao nhat");
				
				int maxIndex = 0;
				double maxSalary;
				maxSalary = listTeachers.get(0).tinhLuong();
				
				for( i = 0; i < listTeachers.size(); i++) {
					if(listTeachers.get(i).tinhLuong() > maxSalary) {
						maxIndex = i;
						maxSalary = listTeachers.get(i).tinhLuong();
					}
				}
				
				System.out.println("Giang vien co luong cao nhat: ");
				listTeachers.get(maxIndex).showInfo();
				break;
			case 4:
				System.out.println("goodbye!");
				exit = true;
				break;
			default:
				System.err.println("Nhap sai! Moi ban nhap lai lua chon");
				break;
			}
		}while(choose != 4);
	}
	
	static void menu() {
		System.out.println("===================================================");
		System.out.println("1. Nhap vao n giang vien");
		System.out.println("2. Hien thi thong tin tat ca cac giang vien ");
		System.out.println("3. Hien thi giang vien co luong cao nhat");
		System.out.println("4. Thoat");
		System.out.println("===================================================");
	}
}






Phạm Kim Anh [JavaFree]
Phạm Kim Anh

2020-03-25 16:44:48



package quanlysinhvien_giaovien;

import java.util.Scanner;

public class Person {

	private String name;
	private String gender;
	private String dateOfBirth;
	private String address;
	
	final static Scanner sc = new Scanner(System.in);
	public Person() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param name
	 * @param gender
	 * @param dateOfBirth
	 * @param address
	 */
	public Person(String name, String gender, String dateOfBirth, String address) {
		super();
		this.name = name;
		this.gender = gender;
		this.dateOfBirth = dateOfBirth;
		this.address = address;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(String dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	public void inputInfo() {
		System.out.println("Moi ban nhap ten: ");
		name = sc.nextLine();
		
		System.out.println("Moi ban nhap gioi tinh: ");
		gender = sc.nextLine();
		
		System.out.println("Moi ban nhap ngay sinh: ");
		dateOfBirth = sc.nextLine();
		
		System.out.println("Moi ban nhap dia chi: ");
		address = sc.nextLine();
	}
	
	public void showInfo() {
		System.out.println("------------------------------");
		System.out.println("Ten : "+name);
		System.out.println("Gioi tinh: "+gender);
		System.out.println("Ngay sinh: "+dateOfBirth);
		System.out.println("Dia chi: "+address);
	}
}

package quanlysinhvien_giaovien;

public class Student extends Person{

	private String id;
	private float mark;
	private String email;
	
	public Student() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param id
	 * @param mark
	 * @param email
	 */
	public Student(String id, float mark, String email) {
		super();
		this.id = id;
		this.mark = mark;
		this.email = email;
	}

	public String getId() {
		return id;
	}

	public boolean setId(String id) {
		if(id != null && id.length()==8) {
			this.id = id;
			return true;
		} else {
			System.err.println("Moi ban nhap lai ma sinh vien (do dai = 8 ki tu): ");
			return false;
		}
		
	}

	public float getMark() {
		return mark;
	}

	public boolean setMark(float mark) {
		if(mark >= 0 && mark <= 10) {
			this.mark = mark;
			return true;
		} else {
			System.err.println("Moi ban nhap lai diem(diem >= 0 && diem <= 10): ");
			return false;
		}
		
	}

	public String getEmail() {
		return email;
	}

	public boolean setEmail(String email) {
		if(email != null && !email.contains("") && email.contains("@")) {
			this.email = email;
			return true;
		} else {
			System.err.println("Moi ban nhap lai email(email khong de trong, khong chua khoang trang va chua dau @): ");
			return false;
		}
		
	}
	
	@Override
	public void inputInfo() {
		super.inputInfo();
		
		System.out.println("Moi ban nhap ma sinh vien: ");
		while(true) {
			String masv = sc.nextLine();
			boolean check = setId(masv);
			if (check) {
				break;
			}
		}
		
		System.out.println("Moi ban nhap diem trung binh: ");
		while(true) {
			float diemTB = Float.parseFloat(sc.nextLine());
			boolean check = setMark(diemTB);
			if(check) {
				break;
			}
		}
		
		System.out.println("Moi ban nhap email: ");
		while(true) {
			String email = sc.nextLine();
			boolean check = setEmail(email);
			if(check) {
				break;
			}
		}
	}
	
	@Override
	public void showInfo() {
		super.showInfo();
		System.out.println("Ma sinh vien: "+id);
		System.out.println("Diem trung binh: "+mark);
		System.out.println("Email: "+email);
		System.out.println();
	}
	
	public boolean checkScholarship() {
		if(mark > 8.0) {
			return true;
		}
		return false;
	}
}

package quanlysinhvien_giaovien;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class StudentTest {

	public static void main(String[] args) {
		 
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Student> listStd = new ArrayList<Student>();

		int choose;
		boolean exit = false;
		int i;
		do {
			Menu();
			System.out.println("Moi ban nhap lua chon: ");
			choose = Integer.parseInt(sc.nextLine());
			switch(choose) {
			
			case 1:
				System.out.println("1. Nhap vao n sinh vien");
				
				System.out.println("Moi ban nhap so sinh vien can them: ");
				int n = Integer.parseInt(sc.nextLine());
				for(i = 0; i <n; i++) {
					Student st = new Student();
					st.inputInfo();
					listStd.add(st);
				}
				break;
			
			case 2:
				System.out.println("2. Hien thi tat ca cac sinh vien ra man hinh");
				
				for( i = 0; i < listStd.size(); i++) {
					listStd.get(i).showInfo();
				}
				break;
			
			case 3:
				System.out.println("3. Hien thi sinh vien co diem trung binh cao nhat \n va sinh vien co diem trung binh thap nhat");
				
				int minIndex = 0, maxIndex = 0;
				float minMark, maxMark;
				
				minMark = listStd.get(0).getMark();
				maxMark = listStd.get(0).getMark();
				
				for( i = 1; i < listStd.size(); i++) {
					if(listStd.get(i).getMark() < minMark) {
						minIndex = i;
						minMark = listStd.get(i).getMark();
					}
					if(listStd.get(i).getMark() > maxMark) {
						maxIndex = i;
						maxMark = listStd.get(i).getMark();
					}
				}
				
				System.out.println("Sinh vien co diem cao nhat la: ");
				listStd.get(maxIndex).showInfo();
				
				System.out.println("Sinh vien co diem thap nhat la: ");
				listStd.get(minIndex).showInfo();
				break;
			
			case 4:
				System.out.println("4. Tim kiem sinh vien theo ma sinh vien");
				
				System.out.println("Moi ban nhap ma sinh vien can tim: ");
				String id = sc.nextLine();
				int dem = 0;
				
				for(Student st : listStd) {
					if (st.getId().equalsIgnoreCase(id)) {
						st.showInfo();
						dem++;
					}
				}
				if(dem == 0) {
					System.out.println("Khong tim thay sinh vien nao co id = "+id);
				}
				break;
			
			case 5:
				System.out.println("5. Hiem thi tat ca cac sinh vien theo thu tu ten trong bang chu cai");
				
				Collections.sort(listStd, new Comparator<Student>() {

					@Override
					public int compare(Student o1, Student o2) {
						int cmp = o1.getName().compareTo(o2.getName());
						if(cmp >= 0) {
							return 1;
						}
						return -1;
					}
				});
				
				for( i = 0; i < listStd.size(); i++) {
					listStd.get(i).showInfo();
				}
				break;
			
			case 6:
				System.out.println("6. Hien thi tat ca cac sinh vien duoc hoc bong \n va sap xep theo thu tu diem cao xuong thap ");
				
				Collections.sort(listStd, new Comparator<Student>() {

					@Override
					public int compare(Student o1, Student o2) {
						return o1.getMark() >= o2.getMark() ? -1:1;
					}
				});
				
				for(i = 0; i <listStd.size(); i++) {
					if(listStd.get(i).checkScholarship()) {
						listStd.get(i).showInfo();
					}
				}
				break;
			
			case 7:
				System.out.println("goodbye!");
				exit = true;
				break;
			
			default:
				System.err.println("Nhap sai! Moi ban nhap lai lua chon");
				break;
			}
		} while(choose != 7);
	}
	
	static void Menu() {
		System.out.println("=========================================================================");
		System.out.println("1. Nhap vao n sinh vien");
		System.out.println("2. Hien thi thong tin tat ca sinh vien ra man hinh");
		System.out.println("3. Hien thi sinh vien co diem trung binh cao nhat \n va sinh vien co diem trung binh thap nhat");
		System.out.println("4. Tim kiem sinh vien theo ma sinh vien");
		System.out.println("5. Hien thi tat ca cac sinh vien theo thu tu ten trong bang chu cai");
		System.out.println("6. Hien thi tat ca cac sinh vien duoc hoc bong \n va sap xep theo thu tu diem cao xuong thap ");
		System.out.println("7. Thoat");
		System.out.println("=========================================================================");
	}
}


package quanlysinhvien_giaovien;

public class Teacher extends Person{

	//Lop day : vd C1011L
	private String teachingClass;
	//luong 1 gio day
	private float salary;
	//so gio day trong thang
	private float hour;
	
	public Teacher() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param teachingClass
	 * @param salary
	 * @param hour
	 */
	public Teacher(String teachingClass, float salary, float hour) {
		super();
		this.teachingClass = teachingClass;
		this.salary = salary;
		this.hour = hour;
	}

	public String getTeachingClass() {
		return teachingClass;
	}

	public void setTeachingClass(String teachingClass) {
		this.teachingClass = teachingClass;
	}

	public float getSalary() {
		return salary;
	}

	public void setSalary(float salary) {
		this.salary = salary;
	}

	public float getHour() {
		return hour;
	}

	public void setHour(float hour) {
		this.hour = hour;
	}
	
	@Override
	public void inputInfo() {
		super.inputInfo();
		System.out.println("Moi ban nhap lop day: ");
		teachingClass = sc.nextLine();
		System.out.println("Moi ban nhap luong mot gio day: ");
		salary = Float.parseFloat(sc.nextLine());
		System.out.println("Moi ban nhap so gio day trong thang: ");
		hour = Float.parseFloat(sc.nextLine());
	}
	
	@Override
	public void showInfo() {
		super.showInfo();
		System.out.println("Lop day: "+teachingClass);
		System.out.println("Luong mot gio day: "+salary);
		System.out.println("So gio day trong thang: "+hour);
	}
	
	public double tinhLuong() {
		double luong = salary * hour;
		char c = teachingClass.charAt(5);
		if(Character.toString(c).equals("M") || Character.toString(c).equals("L")) {
			luong = luong + 200000;
		}
		return luong;
	}
}

package quanlysinhvien_giaovien;

import java.util.ArrayList;
import java.util.Scanner;

public class TeacherTest {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Teacher> listTeachers = new ArrayList<Teacher>();
		
		int choose;
		boolean exit = false;
		int i;
		do {
			menu();
			System.out.println("Moi ban nhap lua chon: ");
			choose = Integer.parseInt(sc.nextLine());
			switch(choose) {
			case 1:
				System.out.println("1. Nhap vao n giang vien");
				
				System.out.println("Moi ban nhap so giang vien muon them: ");
				int n = Integer.parseInt(sc.nextLine());
				
				for(i = 0; i < n; i++) {
					Teacher teacher = new Teacher();
					teacher.inputInfo();
					listTeachers.add(teacher);
				}
				break;
			case 2:
				System.out.println("2. Hien thi thong tin tat ca cac giang vien ");
				for(Teacher t : listTeachers) {
					t.showInfo();
				}
				break;
			case 3:
				System.out.println("3. Hien thi giang vien co luong cao nhat");
				
				int maxIndex = 0;
				double maxSalary;
				maxSalary = listTeachers.get(0).tinhLuong();
				
				for( i = 0; i < listTeachers.size(); i++) {
					if(listTeachers.get(i).tinhLuong() > maxSalary) {
						maxIndex = i;
						maxSalary = listTeachers.get(i).tinhLuong();
					}
				}
				
				System.out.println("Giang vien co luong cao nhat: ");
				listTeachers.get(maxIndex).showInfo();
				break;
			case 4:
				System.out.println("goodbye!");
				exit = true;
				break;
			default:
				System.err.println("Nhap sai! Moi ban nhap lai lua chon");
				break;
			}
		}while(choose != 4);
	}
	
	static void menu() {
		System.out.println("===================================================");
		System.out.println("1. Nhap vao n giang vien");
		System.out.println("2. Hien thi thong tin tat ca cac giang vien ");
		System.out.println("3. Hien thi giang vien co luong cao nhat");
		System.out.println("4. Thoat");
		System.out.println("===================================================");
	}
}






trung [C1907L]
trung

2020-03-21 16:42:27



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Person {
    String ten;
    String gioiTinh;
    String ngaySinh;
    String diaChi;

    public Person() {
    }

    public Person(String ten, String gioiTinh, String ngaySinh, String diaChi) {
        this.ten = ten;
        this.gioiTinh = gioiTinh;
        this.ngaySinh = ngaySinh;
        this.diaChi = diaChi;
    }

    public String getten() {
        return ten;
    }

    public String getGioiTinh() {
        return gioiTinh;
    }

    public String getNgaySinh() {
        return ngaySinh;
    }

    public String getDiaChi() {
        return diaChi;
    }

    public void setten(String ten) {
        this.ten = ten;
    }

    public void setGioiTinh(String gioiTinh) {
        this.gioiTinh = gioiTinh;
    }

    public void setNgaySinh(String ngaySinh) {
        this.ngaySinh = ngaySinh;
    }

    public void setDiaChi(String diaChi) {
        this.diaChi = diaChi;
    }
    
    public void inputInfo() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap vao ten : ");
        this.ten = input.nextLine();

        System.out.println("Nhap vao gioi tinh: ");
        this.gioiTinh = input.nextLine();

        System.out.println("Nhap vao ngay sinh: ");
        this.ngaySinh = input.nextLine();

        System.out.println("Nhap vao dia chi: ");
        this.diaChi = input.nextLine();
    }
    
    public void showInfo() {
        System.out.format("ten : %s\n", this.ten);
        System.out.format("gioi tinh: %s\n", this.gioiTinh);
        System.out.format("ngay sinh: %s\n", this.ngaySinh);
        System.out.format("dia chi: %s\n", this.diaChi);
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;
import java.util.Scanner;
/**
 *
 * @author prdox
 */
public class Student extends Person{
    String maSinhVien;
    float diemTrungBinh;
    String email;
    
    @Override
    public void inputInfo() {
        Scanner input = new Scanner(System.in);
        super.inputInfo();
        String maSv;
        while (true){
            System.out.println("Nhap vao ma Sinh vien");
            maSv = input.nextLine();
            if (maSv.length() == 8) break;
            else {
                System.out.println("Ma SV phai co 8 ky tu");
            }
        }
        this.maSinhVien = maSv;
        
        float diemTrungBinh;
        while (true){
            System.out.println("Nhap vao diem trung binh");
            diemTrungBinh = Float.parseFloat(input.nextLine());
            if (diemTrungBinh < 10.0 && diemTrungBinh > 0.0) break;
            else{
                System.out.println("Diem trung binh phai nam giua 0 va 10");
            }
        }
        this.diemTrungBinh = diemTrungBinh;
        
        String email;
        while (true){
            System.out.println("Nhap vao email");
            email = input.nextLine();
            if (!email.contains(" ") && email.contains("@")) break;
            else{
                System.out.println("Phai co @ va khong co dau cach");
            }
        }
        this.email = email;
    }
    
    @Override
    public void showInfo() {
        super.showInfo();
        System.out.format("Ma SV : %s\n", this.maSinhVien);
        System.out.format("Diem trung binh: %s\n", this.diemTrungBinh);
        System.out.format("Email : %s\n", this.email);
    }
    
    public boolean checkHB(){
        return (this.diemTrungBinh>8);
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class StudentTest {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = 0,i = 0;
        int option;
        ArrayList<Student> arr = new ArrayList<>();
        Boolean exit = false;
        while (!exit) {
            System.out.println("Chọn 1: Nhập vào n sinh viên (n là số lượng sinh viên, được nhập từ bàn phím)");
            System.out.println("Chọn 2: Hiển thị thông tin tất cả các sinh viên ra màn hình");
            System.out.println("Chọn 3: Hiển thị sinh viên có điểm trung bình cao nhất và sinh viên có điểm trung bình thấp nhất");
            System.out.println("Chọn 4: Tìm kiếm sinh viên theo mã sinh viên. Nhập vào mã sinh viên.");
            System.out.println("Chọn 5: Hiển thị tất cả các sinh viên theo thứ tự tên trong bảng chữ cái (A->Z)");
            System.out.println("Chọn 6: Hiển thị tất cả các sinh viên được học bổng, và sắp xếp theo thứ tự điểm cao xuống thấp");
            System.out.println("Chọn 7: Thoát");
            try {
                option = Integer.parseInt(input.nextLine());
            } catch (NumberFormatException e) {
                System.out.println("Input invalid !");
                continue;
            }
            switch (option) {
                case 1:
                    arr.clear();
                    System.out.println("Nhap vao so luong sinh vien");
                    N = Integer.parseInt(input.nextLine());
                    for (i = 0; i < N; i++) {
                        arr.add(new Student());
                        arr.get(arr.size() - 1).inputInfo();
                    }
                    break;
                case 2:
                    for (i = 0; i < N; i++) {
                        arr.get(arr.size() - 1).showInfo();
                    }
                    break;
                case 3:
                    int min=0,max=0;
                    float diemMin = arr.get(0).diemTrungBinh;
                    float diemMax = diemMin;
                    if (arr.isEmpty()) break;
                    for (i = 0; i < N; i++) {
                        if (arr.get(i).diemTrungBinh>diemMax) {
                            diemMax = arr.get(i).diemTrungBinh;
                            max = i;
                        }
                        if (arr.get(i).diemTrungBinh<diemMin) {
                            diemMin = arr.get(i).diemTrungBinh;
                            min = i;
                        }
                    }
                    System.out.format("Sinh vien co diem cao nhat la %s",arr.get(max).ten);
                    System.out.format("Sinh vien co diem thap nhat la %s",arr.get(min).ten);
                    break;
                case 4:
                    System.out.println("Nhap vao ma sinh vien");
                    String maSv = input.nextLine();
                    for (i=0; i < N; i++) {
                        if (arr.get(i).maSinhVien.equals(maSv)) {
                            arr.get(i).showInfo();
                            break;
                        }
                    }
                    if (i==N){
                        System.out.println("Khong ton tai ma sinh vien nay!");
                    }
                    break;
                case 5:
                    //Hien thi tat ca sinh vien theo thu tu A->Z
                    for (i = 0; i < N - 1; i++) {
                        for (int j = i + 1; j < N; j++) {
                            if (arr.get(i).ten.compareTo(arr.get(j).ten)>0) {
                                Student temp = arr.get(j);
                                arr.set(j, arr.get(i));
                                arr.set(i, temp);
                            }
                        }
                    }
                    for (i = 0; i < N; i++) {
                        arr.get(arr.size() - 1).showInfo();
                    }
                    break;
                    
                case 6:
                    for (i = 0; i < N - 1; i++) {
                        for (int j = i + 1; j < N; j++) {
                            if (arr.get(i).diemTrungBinh < arr.get(j).diemTrungBinh) {
                                Student temp = arr.get(j);
                                arr.set(j, arr.get(i));
                                arr.set(i, temp);
                            }
                        }
                    }
                    for (i = 0; i < N; i++) {
                        if (arr.get(i).checkHB()){
                            arr.get(arr.size() - 1).showInfo();
                        }
                    }
                    break;
                case 7:
                    exit = true;
                    break;

            }
        }
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class Teacher extends Person {

    String lop;
    int luong, soGioDay;

    @Override
    public void inputInfo() {
        super.inputInfo();
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap vao lop dang day : ");
        this.lop = input.nextLine();
        System.out.println("Nhap vao luong 1 gio : ");
        this.luong = Integer.parseInt(input.nextLine());
        System.out.println("Nhap vao so gio day : ");
        this.soGioDay = Integer.parseInt(input.nextLine());
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.format("lop dang day : %s\n", this.lop);
        System.out.format("luong 1 gio : %d\n", this.luong);
        System.out.format("so gio day : %d\n", this.soGioDay);
    }

    public int tinhLuong() {
        char type = this.lop.charAt(this.lop.length() - 1);
        if ("GHIK".indexOf(type) > 0) {
            return (this.luong * this.soGioDay);
        } else {
            return (this.luong * this.soGioDay + 200000);
        }

    }

//    public static void main(String[] args) {
//        Teacher a = new Teacher();
//        a.tinhLuong();
//    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author prdox
 */
public class TeacherTest {
    private static int getInt(){
        Scanner input = new Scanner(System.in);
        while(true){
            try {
                return Integer.parseInt(input.nextLine());
            } catch (Exception e) {
                System.out.println("Please input integer");
            }
        }
    }
    
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = 0, i = 0;
        int option;
        ArrayList<Teacher> arr = new ArrayList<>();
        Boolean exit = false;
        while (!exit) {
            System.out.println("a. Chọn 1: Nhập vào n giảng viên (n là số lượng sinh viên, được nhập từ bàn phím)");
            System.out.println("b. Chọn 2: Hiển thị thông tin tất cả các giảng viên ra màn hình");
            System.out.println("c. Chọn 3: Hiển thị giảng viên có lương cao nhất");
            System.out.println("d. Chọn 4: Thoát");
            option = getInt();
            switch(option){
                case 1:
                    arr.clear();
                    System.out.println("Nhap vao so luong giang vien");
                    N = getInt();
                    for (i = 0; i < N; i++){
                        Teacher teacher = new Teacher();
                        teacher.inputInfo();
                        arr.add(teacher);
                    }
                    break;
                case 2:
                    for (Teacher teacher:arr){
                        teacher.showInfo();
                    }
                    break;
                case 3:
                    Teacher max = arr.get(0);
                    int luongMax = max.tinhLuong();
                    for (Teacher teacher:arr){
                        int luong = teacher.tinhLuong();
                        if (luong > luongMax){
                            luongMax = luong;
                            max = teacher;
                        }
                    }
                    System.out.println("Giang vien co luong cao nhat la:");
                    max.showInfo();
                    break;
                case 4:
                    exit = true;
                    break;
                    
            }
        }
    }
}



Nguyễn Hoàng Anh [C1907L]
Nguyễn Hoàng Anh

2020-03-20 08:37:03



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

import java.util.*;

/**
 *
 * @author Redmibook 14
 */
class MarkComparator implements Comparator<Student> {

    public int compare(Student s1, Student s2) {
        if (s1.DiemTrungBinh == s2.DiemTrungBinh) {
            return 0;
        } else if (s1.DiemTrungBinh < s2.DiemTrungBinh) {
            return 1;
        } else {
            return -1;
        }

    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

/**
 *
 * @author Redmibook 14
 */
import java.util.*;

class NameComparator implements Comparator<Student> {
	public int compare(Student s1, Student s2) {
		return s1.Ten.compareTo(s2.Ten);
	}
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

/**
 *
 * @author Redmibook 14
 */
public class Person {

    String Ten, GioiTinh, NgaySinh, DiaChi;

    public Person() {
    }

    public Person(String Ten, String GioiTinh, String NgaySinh, String DiaChi) {
        this.Ten = Ten;
        this.GioiTinh = GioiTinh;
        this.NgaySinh = NgaySinh;
        this.DiaChi = DiaChi;
    }

    public void setTen(String Ten) {
        this.Ten = Ten;
    }

    public void setGioiTinh(String GioiTinh) {
        this.GioiTinh = GioiTinh;
    }

    public void setNgaySinh(String NgaySinh) {
        this.NgaySinh = NgaySinh;
    }

    public void setDiaChi(String DiaChi) {
        this.DiaChi = DiaChi;
    }

    public String getTen() {
        return Ten;
    }

    public String getGioiTinh() {
        return GioiTinh;
    }

    public String getNgaySinh() {
        return NgaySinh;
    }

    public String getDiaChi() {
        return DiaChi;
    }

    public void inputInfo(String Ten, String GioiTinh, String NgaySinh, String DiaChi) {
        this.Ten = Ten;
        this.GioiTinh = GioiTinh;
        this.NgaySinh = NgaySinh;
        this.DiaChi = DiaChi;
    }

    public void showInfo() {
        System.out.println("Ten : " + Ten);
        System.out.println("Gioi tinh : " + GioiTinh);
        System.out.println("Ngay sinh : " + NgaySinh);
        System.out.println("Dia chi : " + DiaChi);
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

import java.util.*;

/**
 *
 * @author Redmibook 14
 */
public class PersonTest {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        System.out.println("Ten : ");
        String ten = input.nextLine();
        System.out.println("Gioi Tinh : ");
        String GioiTinh = input.nextLine();
        System.out.println("Ngay Sinh : ");
        String NgaySinh = input.nextLine();
        System.out.println("Dia Chi : ");
        String DiaChi = input.nextLine();
        Person person = new Person(ten, GioiTinh, NgaySinh, DiaChi);
        System.out.println("Ten : " + person.getTen());
        System.out.println("Gioi Tinh : " + person.getGioiTinh());
        System.out.println("Ngay Sinh : " + person.getNgaySinh());
        System.out.println("Dia Chi : " + person.getDiaChi());
       
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

/**
 *
 * @author Redmibook 14
 */
public class Student extends Person {

    String MaSinhVien;
    float DiemTrungBinh;
    String Email;

    @Override
    public void inputInfo(String Ten, String GioiTinh, String NgaySinh, String DiaChi) {
        super.inputInfo(Ten, GioiTinh, NgaySinh, DiaChi);
    }

    public void inputInfo(String MaSinhVien, float DiemTrungBinh, String Email, int flag) {

        if (MaSinhVien.length() < 8) {
            this.MaSinhVien = MaSinhVien;
        } else {
            System.out.println("Ma sinh vien phai it hon 8 ki tu.");
            flag = 2;
        }
        if (DiemTrungBinh > 0 && DiemTrungBinh <= 10) {
            this.DiemTrungBinh = DiemTrungBinh;
        } else {
            System.out.println("Diem trung binh phai tu 0 - 10.");
            flag = 2;
        }
        if (Email.matches("^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$")) {
            this.Email = Email;
        } else {
            System.out.println("phải chứa kí tự @ và không tồn tại khoảng trắng.");
            flag = 2;
        }
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println("Ma sinh vien : " + MaSinhVien);
        System.out.println("Diem trung binh : " + DiemTrungBinh);
        System.out.println("Email : " + Email);
    }

    public void hocBong() {
        if (DiemTrungBinh > 8) {
            System.out.println("Duoc hoc bong");
        }
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

import java.util.*;

/**
 *
 * @author Redmibook 14
 */
public class StudentTest {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Student student = new Student();

        ArrayList<Student> arr = new ArrayList();
        while (true) {
            System.out.println("Chọn 1: Nhập vào sinh viên");
            System.out.println("Chọn 2: Hiển thị thông tin tất cả các sinh viên ra màn hình");
            System.out.println("Chọn 3: Hiển thị sinh viên có điểm trung bình cao nhất và sinh viên có điểm trung bình thấp nhất");
            System.out.println("Chọn 4: Tìm kiếm sinh viên theo mã sinh viên. Nhập vào mã sinh viên.");
            System.out.println("Chọn 5: Hiển thị tất cả các sinh viên theo thứ tự tên trong bảng chữ cái (A->Z)");
            System.out.println("Chọn 6: Hiển thị tất cả các sinh viên được học bổng, và sắp xếp theo thứ tự điểm cao xuống thấp");
            System.out.println("Chọn 7: Thoát");
            String choice = input.nextLine();
            switch (choice) {
                case "1":
                    System.out.println("Nhập số lượng sinh viên : ");
                    int n = Integer.parseInt(input.nextLine());
                    for (int i = 0; i < n; i++) {
                        int flag = 1;
                        System.out.println("Nhâp thông tin sinh viên thứ " + (i + 1));
                        System.out.println("Nhâp tên : ");
                        String Ten = input.nextLine();
                        System.out.println("Nhâp giới tính : ");
                        String GioiTinh = input.nextLine();
                        System.out.println("Nhâp ngày sinh : ");
                        String NgaySinh = input.nextLine();
                        System.out.println("Nhâp địa chỉ : ");
                        String DiaChi = input.nextLine();
                        System.out.println("Mã sinh viên : ");
                        String Msv = input.nextLine();
                        if (!(Msv.length() < 8)) {
                            System.out.println("Ma sinh vien phai it hon 8 ki tu.");
                            break;
                        }
                        System.out.println("Nhâp điểm trung bình : ");
                        float Diem = Float.parseFloat(input.nextLine());
                        if (!(Diem > 0 && Diem <= 10)) {
                            System.out.println("Diem trung binh phai tu 0 - 10.");
                            break;
                        }
                        System.out.println("Nhâp email : ");
                        String Email = input.nextLine();
                        if (!Email.matches("^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$")) {
                            System.out.println("phải chứa kí tự @ và không tồn tại khoảng trắng.");
                            break;
                        }
                        student = new Student();
                        student.inputInfo(Ten, GioiTinh, NgaySinh, DiaChi);
                        student.inputInfo(Msv, Diem, Email, flag);
                        if (flag == 2) {
                            return;
                        }
                        arr.add(student);
                    }

                    break;
                case "2":
                    for (int i = 0; i < arr.size(); i++) {
                        arr.get(i).showInfo();
                        System.out.println("---------");
                    }
                    break;
                case "3":
                    Student max = new Student();
                    Student min = new Student();
                    for (int i = 0; i < arr.size(); i++) {
                        for (int j = 0; j < arr.size(); j++) {
                            if (arr.get(i).DiemTrungBinh < arr.get(j).DiemTrungBinh) {
                                max = arr.get(j);
                            }
                            if (arr.get(i).DiemTrungBinh > arr.get(j).DiemTrungBinh) {
                                min = arr.get(j);
                            }
                        }

                    }
                    System.out.println("Hs co diem cao nhat");
                    max.showInfo();
                    System.out.println("Hs co diem thap nhat");
                    min.showInfo();
                    break;
                case "4":
                    System.out.println("Nhap ma sinh vien : ");
                    String ma = input.nextLine();
                    Student temp = new Student();
                    int flag = 1;
                    for (int i = 0; i < arr.size(); i++) {
                        if (ma.equals(arr.get(i).MaSinhVien) == true) {
                            flag = 2;
                            arr.get(i).showInfo();

                        }
                    }
                    if (flag == 1) {
                        System.out.println("Khong co sinh vien nao.");
                    }

                    break;
                case "5":
                    Collections.sort(arr, new NameComparator());
                    for (int i = 0; i < arr.size(); i++) {
                        arr.get(i).showInfo();
                        System.out.println("---------");
                    }
                    break;
                case "6":
                    System.out.println("Cac sinh vien duoc hoc bong : ");
                    ArrayList<Student> arrTemp = new ArrayList();
                    for (int i = 0; i < arr.size(); i++) {
                        if (arr.get(i).DiemTrungBinh > 8) {
                            arrTemp.add(arr.get(i));
                        }
                    }
                    Collections.sort(arrTemp, new MarkComparator());
                    for (int i = 0; i < arrTemp.size(); i++) {
                        arrTemp.get(i).showInfo();
                        System.out.println("---------");
                    }
                    break;
                case "7":
                    return;

            }
        }
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

import java.util.*;

/**
 *
 * @author Redmibook 14
 */
public class Teacher extends Person {

    String Lop;
    float LuongMotGio;
    float SoGioDayTrongThang;

    @Override
    public void inputInfo(String Ten, String GioiTinh, String NgaySinh, String DiaChi) {
        super.inputInfo(Ten, GioiTinh, NgaySinh, DiaChi);
    }

    public void inputInfo(String Lop, float LuongMotGio, float SoGioDayTrongThang) {
        this.Lop = Lop;
        this.LuongMotGio = LuongMotGio;
        this.SoGioDayTrongThang = SoGioDayTrongThang;
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println("Lop : " + Lop);
        System.out.println("Luong mot gio : " + LuongMotGio);
        System.out.println("So gio day trong thang : " + SoGioDayTrongThang);

    }

    public float TinhLuong() {
        float n = 0;
        if ((Lop.substring(Lop.length() - 1)).toLowerCase().equals("i") == true
                || (Lop.substring(Lop.length() - 1)).toLowerCase().equals("k") == true
                || (Lop.substring(Lop.length() - 1)).toLowerCase().equals("l") == true
                || (Lop.substring(Lop.length() - 1)).toLowerCase().equals("m") == true) {
            n = LuongMotGio * SoGioDayTrongThang;
            return n;
        }
        if ((Lop.substring(Lop.length() - 1)).toLowerCase().equals("l") == true
                || (Lop.substring(Lop.length() - 1)).toLowerCase().equals("m") == true) {
            n = LuongMotGio * SoGioDayTrongThang + 200000;
            return n;
        }
        return n;
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package StudentAndTeacherManager;

import java.util.*;

/**
 *
 * @author Redmibook 14
 */
public class TeacherTest {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        ArrayList<Teacher> arr = new ArrayList();

        while (true) {
            System.out.println("1.Nhap vao n giang vien");
            System.out.println("2.Hien thi thong tin cac giang vien");
            System.out.println("3.Hien thi giang vien co luong cao nhat");
            System.out.println("4.Thoat");
            String choice = input.nextLine();
            switch (choice) {
                case "1":

                    System.out.println("Nhap vao so luong giang vien : ");
                    int n = Integer.parseInt(input.nextLine());
                    for (int i = 0; i < n; i++) {
                        Teacher teacher = new Teacher();
                        System.out.println("Nhap thong tin giang vien " + (i + 1));
                        System.out.println("Nhap ten : ");
                        String ten = input.nextLine();
                        System.out.println("Nhap gioi tinh : ");
                        String gioiTinh = input.nextLine();
                        System.out.println("Nhap ngay sinh : ");
                        String ngaySinh = input.nextLine();
                        System.out.println("Nhap dia chi : ");
                        String diaChi = input.nextLine();
                        System.out.println("Nhap lop : ");
                        String regex = "^[a-zA-Z][0-9]{4}[a-zA-Z&&[ghiklmGHIKLM]]$";
                        String lop = input.nextLine();
                        if (!lop.matches(regex)) {
                            System.out.println("Moi nhap dung ma lop (VD: c1903l,C1907I,c1903H)!");
                            break;
                        }
                        System.out.println("Nhap luong mot gio : ");
                        float luong = Float.parseFloat(input.nextLine());
                        System.out.println("Nhap so gio day trong thang : ");
                        float gioday = Float.parseFloat(input.nextLine());
                        teacher.inputInfo(ten, gioiTinh, ngaySinh, diaChi);
                        teacher.inputInfo(lop, luong, gioday);
                        arr.add(teacher);
                    }
                    break;
                case "2":
                    for (int i = 0; i < arr.size(); i++) {
                        arr.get(i).showInfo();
                        System.out.println("............");
                    }
                    break;
                case "3":
                    Teacher teacherMax = new Teacher();
                    ArrayList<Teacher> Temp = new ArrayList();
                    for (int i = 0; i < arr.size(); i++) {
                        for (int j = 0; j < arr.size(); j++) {
                            if (arr.get(i).TinhLuong() < arr.get(j).TinhLuong()) {
                                teacherMax = arr.get(j);
                            }
                        }

                    }
                    teacherMax.showInfo();
                    break;
                case "4":
                    return;
            }
        }

    }
}



Ngô Quang Huy [C1907L]
Ngô Quang Huy

2020-03-19 13:44:53



package StudentTeacher;

import java.util.Scanner;

public class Person {
    String Name;
    String Gender;
    String dob;
    String add;

    public Person() {
    }

    public Person(String Name, String Gender, String dob, String add) {
        this.Name = Name;
        this.Gender = Gender;
        this.dob = dob;
        this.add = add;
    }
    
    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public String getGender() {
        return Gender;
    }

    public void setGender(String Gender) {
        this.Gender = Gender;
    }

    public String getDob() {
        return dob;
    }

    public void setDob(String dob) {
        this.dob = dob;
    }

    public String getAdd() {
        return add;
    }

    public void setAdd(String add) {
        this.add = add;
    }
    
    public void inputInfo(){
        Scanner input = new Scanner(System.in);
        System.out.print("Nhap vao Ten: ");
        Name = input.nextLine();
        System.out.print("Nhap vao Gioi tinh: ");
        Gender = input.nextLine();
        System.out.print("Nhap vao Ngay sinh: ");
        dob = input.nextLine();
        System.out.print("Nhap vao dia chi: ");
        add = input.nextLine();
    }
    
    public void showInfo(){
        System.out.println("\nTên la: "+Name);
        System.out.println("Giới tính la: "+Gender);
        System.out.println("Ngày sinh la: "+dob);
        System.out.println("Địa chỉ la: "+add);
    }
}



package StudentTeacher;

import java.util.Scanner;
import java.util.regex.Pattern;

public class Student extends Person{
    String ID;
    float Avr;
    String Email;

    public Student() {
        
    }

    public Student(String ID, float Avr, String Email) {
        this.ID = ID;
        this.Avr = Avr;
        this.Email = Email;
    }

    public Student(String ID, float Avr, String Email, String Name, String Gender, String dob, String add) {
        super(Name, Gender, dob, add);
        this.ID = ID;
        this.Avr = Avr;
        this.Email = Email;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public float getAvr() {
        return Avr;
    }

    public void setAvr(float Avr) {
        this.Avr = Avr;
    }

    public String getEmail() {
        return Email;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }
    
    public int LengthCheck(){
        if(ID.length()!=8){
            System.err.println("ID phai chua 8 ky tu");
            return 0;
        }
        return 1;
    }
    
    public int DtbCheck(){
        if(Avr<0 || Avr>10){
            System.err.println("Điểm trung bình: từ 0.0 – 10.0");
            return 0;
        }
        return 1;
    }
    
    public int EmailCheck(){
        String reg = "^[a-zA-z0-9+]+@[a-z]+.[a-z]+$";
        if(Pattern.matches(reg, Email) == false){
            System.err.println("phải chứa kí tự @ và không tồn tại khoảng trắng");
            return 0;
        }
        return 1;
    }
    
    public void Scholar(){
        if(Avr>8){
            System.out.println("Hoc sinh duoc nhan hoc bong");
        }else{
            System.out.println("Hoc sinh khong duoc nhan hoc bong");
        }
    }

    @Override
    public void inputInfo() {
        super.inputInfo();
        Scanner input = new Scanner(System.in);
        do{
            System.out.print("Nhap vao ID: ");
            ID =  input.nextLine();
        }while(LengthCheck()==0);
        do{
            System.out.print("Nhap vao Diem trung binh: ");
            Avr =  Float.parseFloat(input.nextLine());
        }while(DtbCheck()==0);
        do{
            System.out.print("Nhap vao Email: ");
            Email =  input.nextLine();
        }while(EmailCheck()==0);
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println("ID la: "+ID);
        System.out.println("Diem trung binh la: "+Avr);
        System.out.println("Email la: "+Email);
        Scholar();
    }
}



package StudentTeacher;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        int n=0;
        ArrayList<Student> arr = new ArrayList<>();
        while(true){
            Scanner input = new Scanner(System.in);
            int choose;
            System.out.println("\n\t1: Nhập vào n sinh viên");
            System.out.println("\t2: Hiển thị thông tin tất cả các sinh viên ra màn hình");
            System.out.println("\t3: Hiển thị sinh viên có điểm trung bình cao nhất và sinh viên có điểm trung bình thấp nhất");
            System.out.println("\t4: Tìm kiếm sinh viên theo mã sinh viên");
            System.out.println("\t5: Hiển thị tất cả các sinh viên theo thứ tự tên trong bảng chữ cái (A->Z)");
            System.out.println("\t6: Hiển thị tất cả các sinh viên được học bổng");
            System.out.println("\t7: Thoát");
            System.out.print("Nhap vao lua chon: ");
            choose = Integer.parseInt(input.nextLine());
            switch(choose){
                case 1:
                    System.out.print("\nNhap vao so hoc sinh: ");
                    n = Integer.parseInt(input.nextLine());
                    for(int i=0;i<n;i++){
                        Student hs = new Student();
                        hs.inputInfo();
                        arr.add(hs);
                    }
                    break;
                case 2:
                    for(int i=0;i<n;i++){
                        arr.get(i).showInfo();
                    }
                    break;
                case 3:
                    float tmpMax = 0;
                    int vtMax=0;
                    float tmpMin = 10;
                    int vtMin=0;
                    for(int i=0;i<n;i++){
                        if(arr.get(i).Avr>tmpMax){
                            tmpMax = arr.get(i).Avr;
                            vtMax=i;
                        }
                        if(arr.get(i).Avr<tmpMin){
                            tmpMin = arr.get(i).Avr;
                            vtMin=i;
                        }
                    }
                    System.out.println("sinh viên có điểm trung bình cao nhất la: "+arr.get(vtMax).Name);
                    System.out.println("sinh viên có điểm trung bình thấp nhất la: "+arr.get(vtMin).Name);
                    break;
                case 4:
                    System.out.print("Nhap vao ID: ");
                    String tmp = input.nextLine();
                    int dk=0;
                    for(int i=0;i<n;i++){
                        if(arr.get(i).getID().equals(tmp)==true){
                            arr.get(i).showInfo();
                            dk=1;
                            break;
                        }
                    }
                    if(dk==0){
                         System.out.println("Không có sinh viên nào có mã là"+tmp);
                    }
                    break;
                case 5:
                    for(int i=0;i<n-1;i++){
                        for(int j=i+1;j<n;j++){
                            if((int)arr.get(i).Name.charAt(0) > (int)arr.get(j).Name.charAt(0)){
                                Collections.swap(arr, i, j);
                            }
                        }
                    }
                    for(int i=0;i<n;i++){
                        arr.get(i).showInfo();
                    }
                    break;
                case 6:
                    for(int i=0;i<n-1;i++){
                        for(int j=i+1;j<n;j++){
                            if(arr.get(i).Avr < arr.get(j).Avr){
                                Collections.swap(arr, i, j);
                            }
                        }
                    }
                    for(int i=0;i<n;i++){
                        if(arr.get(i).Avr>8){
                            arr.get(i).showInfo();
                        }else{
                            break;
                        }
                    }
                    break;
                case 7:
                    System.exit(0);
                    break;
            }
        }
    }
}



package StudentTeacher;

import java.util.Scanner;

public class Teacher extends Person{
    String lop;
    int luong;
    int sogio;
    int paid=0;

    public Teacher() {
    }

    public Teacher(String lop, int luong, int sogio) {
        this.lop = lop;
        this.luong = luong;
        this.sogio = sogio;
    }

    public Teacher(String lop, int luong, int sogio, String Name, String Gender, String dob, String add) {
        super(Name, Gender, dob, add);
        this.lop = lop;
        this.luong = luong;
        this.sogio = sogio;
    }

    public String getLop() {
        return lop;
    }

    public void setLop(String lop) {
        this.lop = lop;
    }

    public int getLuong() {
        return luong;
    }

    public void setLuong(int luong) {
        this.luong = luong;
    }

    public int getSogio() {
        return sogio;
    }

    public void setSogio(int sogio) {
        this.sogio = sogio;
    }

    @Override
    public void inputInfo() {
        super.inputInfo();
        Scanner input = new Scanner(System.in);
        System.out.print("Nhap vao lop: ");
        lop = input.nextLine();
        System.out.print("Nhap vao Luong 1h: ");
        luong = Integer.parseInt(input.nextLine());
        System.out.print("Nhap vao So gio: ");
        sogio = Integer.parseInt(input.nextLine());
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println("Lop la: "+lop);
        System.out.println("Lop la: "+luong);
        System.out.println("Lop la: "+sogio);
    }
    
    public int TinhLuong(){
        int so = luong*sogio;
        char c = lop.charAt(5);
        if( Character.toString(c).equals("M") || Character.toString(c).equals("L") ){
            so=so+200000;
        }
        return so;
    }
}



package StudentTeacher;

import java.util.ArrayList;
import java.util.Scanner;

public class TeacherTest {
    public static void main(String[] args) {
        int n=0;
        ArrayList<Teacher> arr = new ArrayList<>();
        while(true){
            Scanner input = new Scanner(System.in);
            System.out.println("\n\t1: Nhập vào n giảng viên");
            System.out.println("\t2: Hiển thị thông tin tất cả các giảng viên ra màn hình");
            System.out.println("\t3: Hiển thị giảng viên có lương cao nhất");
            System.out.println("\t4: Thoát");
            System.out.print("Chon: ");
            int chon = Integer.parseInt(input.nextLine());
            switch(chon){
                case 1:
                    System.out.print("Nhap n: ");
                    n = Integer.parseInt(input.nextLine());
                    for(int i=0;i<n;i++){
                        Teacher tc = new Teacher();
                        tc.inputInfo();
                        arr.add(tc);
                    }
                    break;
                case 2:
                    for(int i=0;i<n;i++){
                        arr.get(i).showInfo();
                    }
                    break;
                case 3:
                    int max=0;
                    int vt=0;
                    for(int i=0;i<n;i++){
                        if(arr.get(i).TinhLuong()>max){
                            max=arr.get(i).TinhLuong();
                            vt=i;
                        }
                    }
                    System.out.print("Hiển thị giảng viên có lương cao nhất: "+arr.get(vt).Name);
                    break;
                case 4:
                    break;
            }
        }
    }
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-19 05:56:11



package aptech;
import java.util.Scanner;

public class TeacherTest {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        Teacher[] teachers;
        int n;
        
        while(true){
            System.out.println("Vui lòng nhập: \n1: Nhập vào n giảng viên\n2: Hiển thị thông tin tất cả các giảng viên\n3: Hiển thị giảng viên có lương cao nhất\n4: Thoát");
            int chon = Integer.parseInt(input.nextLine());
            switch(chon){
                case 1:
                    System.out.print("Nhập số giảng viên: ");
                    n = Integer.parseInt(input.nextLine());
                    teachers = new Teacher[n];
                    for(int i = 0; i < n; i++){
                        teachers[i].inputInfo();
                    }
                    break;
                case 2:
                    for(int i = 0; i < teachers.length; i++){
                        teachers[i].showInfo();
                    }
                    break;
                case 3:
                    int max = 0;
                    for(int i = 0; i < teachers.length; i++){
                        if(teachers[i].luongThucNhan() > max){
                            max = teachers[i].luongThucNhan();
                        }
                    }
                    System.out.println("Giảng viên có lương cao nhất là: ");
                    for(int i = 0; i < teachers.length; i++){
                        if(teachers[i].luongThucNhan() == max){
                            teachers[i].showInfo();
                        }
                    }
                    break;
                case 4:
                    break;
                default:
                    System.out.println("Bạn nhập không đúng, vui lòng chọn lại\n");
            }
            if(chon == 4){
                break;
            }
        }
    }
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-19 05:55:37



package aptech;
import java.util.Scanner;

public class Teacher extends Person{
    private String lopDay;
    private int luong,soGioDay;

    public String getLopDay() {
        return lopDay;
    }

    public void setLopDay(String lopDay) {
        this.lopDay = lopDay;
    }

    public int getLuong() {
        return luong;
    }

    public void setLuong(int luong) {
        this.luong = luong;
    }

    public int getSoGioDay() {
        return soGioDay;
    }

    public void setSoGioDay(int soGioDay) {
        this.soGioDay = soGioDay;
    }

    public Teacher() {
    }

    public Teacher(String lopDay, int luong, int soGioDay, String ten, String gioiTinh, String ngaySinh, String diaChi) {
        super(ten, gioiTinh, ngaySinh, diaChi);
        this.lopDay = lopDay;
        this.luong = luong;
        this.soGioDay = soGioDay;
    }

    @Override
    public void showInfo() {
        super.showInfo(); 
        System.out.println("- Lớp dạy: " + lopDay + "\n- Số tiền một giờ dạy: " + luong + "\n- Số giờ dạy: " + soGioDay);
    }

    @Override
    public void inputInfo() {
        Scanner input = new Scanner(System.in);
        super.inputInfo(); 
        System.out.print("Nhập lớp dạy: ");
        lopDay = input.nextLine();
        System.out.print("Nhập số tiền lương một giờ dạy: ");
        luong = Integer.parseInt(input.nextLine());
        System.out.print("Nhập số giờ dạy: ");
        soGioDay = Integer.parseInt(input.nextLine());
    }
    
    public int luongThucNhan(){
        return (luong * soGioDay);
    }
}



Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-19 05:54:38



package aptech;
import java.util.Scanner;

public class StudentTest {

  
    public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       Student[] students;
       int n;
       
       while(true) {
           System.out.println("Vui lòng chọn: \n1: Nhập vào n sinh viên\n2: Hiển thị thông tin tất cả các sinh viên\n3: Hiển thị sinh viên có điểm trung bình cao nhất và sinh viên có điểm trung bình thấp nhất\n4: Tìm kiếm sinh viên theo mã sinh viên\n5: Hiển thị tất cả các sinh viên theo thứ tự tên trong bảng chữ cái (A->Z)\n6: Hiển thị tất cả các sinh viên được học bổng\n7: Thoát");
           int chon = Integer.parseInt(input.nextLine());
           switch(chon){
               case 1:
                   System.out.print("Nhập số lượng sinh viên: ");
                   n = Integer.parseInt(input.nextLine());
                   students = new Student[n];
                   for(int i = 0; i < n; i++){
                       students[i].inputInfo();
                   }
                   break;
                case 2:
                    System.out.println("Thông tin tất cả sinh viên: ");
                    for(int i = 0; i < students.length; i++){
                       students[i].showInfo();
                   }
                   break;
                case 3:
                    float max = 0;
                    float min = 0;
                    for(int i = 0; i < students.length; i++){
                        if(students[i].getDiemTrungBinh() > max){
                            max = students[i].getDiemTrungBinh();
                        }
                        if(students[i].getDiemTrungBinh() < min){
                            min = students[i].getDiemTrungBinh();
                        }
                    }
                    for(int i = 0; i < students.length; i++){
                        if(students[i].getDiemTrungBinh() == max){
                            System.out.println("Student có điểm cao nhất: ");
                            students[i].showInfo();
                        }
                        if(students[i].getDiemTrungBinh() == min){
                            System.out.println("Student có điểm thấp nhất: ");
                            students[i].showInfo();
                        }
                    }
                   break;
                case 4:
                    System.out.print("Nhập mã sinh viên: ");
                    String msv = input.nextLine();
                    int count = 0;
                    for(int i = 0; i < students.length; i++){
                        if(students[i].getMaSinhVien().equals(msv)){
                            students[i].showInfo();
                            count++;
                        }
                    }
                    if(count == 0){
                        System.out.println("Không có sinh viên nào có mã là: " + msv);
                    }
                   break;
                case 5:
                    System.out.println("Danh sách sinh viên sau khi sắp xếp: ");
                    for(int i = 0; i < students.length - 1 ; i++){
                        for(int y = i + 1; y < student.length; y++){
                            if(students[i].ten.compareTo(students[y].ten) < 0){
                                Student temp = students[i];
                                students[i] = students[y];
                                students[y] = temp;
                            }
                        }
                    }
                    for(int i = 0; i < students.length; i++){
                        students[i].showInfo();
                    }
                   break;
                case 6:
                    for(int i = 0; i < students.length - 1 ; i++){
                        for(int y = i + 1; y < student.length; y++){
                            if(students[i].getDiemTrungBinh() <  students[y].getDiemTrungBinh()){
                                Student temp = students[i];
                                students[i] = students[y];
                                students[y] = temp;
                            }
                        }
                    }
                    System.out.println("Tất cả học sinh, sinh viên được học bổng là: ");
                    for(int i = 0; i < students.length; i++){
                        if(students[i].hocBong()){
                            students[i].showInfo();
                        }
                    }
                   break;
                case 7:
                   break;
                default:
                    System.out.println("Nhập sai, vui lòng chọn lại: \n\n");
           }
           
           if(chon == 7){
               break;
           }
       }
    }
    
}