Created
December 8, 2015 12:07
-
-
Save TuyenGa/9ee3c90dce1c58943fdf to your computer and use it in GitHub Desktop.
Quanlysinhvien kieu array list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SinhVien; | |
public class Main { | |
public static void main(String[] args) | |
{ | |
QLSV2 ql = new QLSV2(); | |
ql.nhap(); | |
ql.in(); | |
ql.timdiem(); | |
ql.timsinhvien(3); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SinhVien; | |
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class QLSV2 { | |
ArrayList<SinhVien> sinhvien = new ArrayList<SinhVien>(); | |
SinhVien sv = new SinhVien(); | |
public void nhap(){ | |
Scanner scan = new Scanner(System.in); | |
System.out.print("nhap sinh so sinh vien: "); | |
int n = scan.nextInt(); | |
for(int i =0 ; i < n ; i++){ | |
sv.nhapThongTinSV(); | |
sinhvien.add(sv); | |
} | |
} | |
public void in() | |
{ | |
for(SinhVien sv : sinhvien) | |
{ | |
sv.xuatThongTinSV(); | |
} | |
} | |
public void timdiem(){ | |
for(SinhVien sv : sinhvien){ | |
if(sv.diem < 4){ | |
sv.xuatThongTinSV(); | |
} | |
} | |
} | |
public void timsinhvien(double diem){ | |
for(SinhVien sv : sinhvien){ | |
if(sv.diem < diem && sv.getHoVaTen().equals("Nguyen van")){ | |
sv.xuatThongTinSV(); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SinhVien; | |
import java.util.Scanner; | |
public class SinhVien | |
{ | |
private String hoVaTen; | |
private int tuoi; | |
private String diaChi; | |
private int soDienThoai; | |
private String Email; | |
double diem; | |
public double getDiem() { | |
return diem; | |
} | |
public void setDiem(double diem) { | |
this.diem = diem; | |
} | |
public String getHoVaTen() { | |
return hoVaTen; | |
} | |
public void setHoVaTen(String hoVaTen) { | |
this.hoVaTen = hoVaTen; | |
} | |
public int getTuoi() { | |
return tuoi; | |
} | |
public void setTuoi(int tuoi) { | |
this.tuoi = tuoi; | |
} | |
public String getDiaChi() { | |
return diaChi; | |
} | |
public void setDiaChi(String diaChi) { | |
this.diaChi = diaChi; | |
} | |
public int getSoDienThoai() { | |
return soDienThoai; | |
} | |
public void setSoDienThoai(int soDienThoai) { | |
this.soDienThoai = soDienThoai; | |
} | |
public String getEmail() { | |
return Email; | |
} | |
public void setEmail(String Email) { | |
this.Email = Email; | |
} | |
protected void nhapThongTinSV() | |
{ | |
Scanner inp = new Scanner(System.in); | |
System.out.print("nhap vao ho ten sinh vien: "); | |
this.hoVaTen = inp.nextLine(); | |
System.out.print("nhap vao Email: "); | |
this.Email = inp.nextLine(); | |
System.out.print("nhap vao dia chi : "); | |
this.diaChi = inp.nextLine(); | |
System.out.print("nhap vao so dien thoai: "); | |
this.soDienThoai = inp.nextInt(); | |
System.out.print("nhap vao tuoi sinh vien: "); | |
this.tuoi = inp.nextInt(); | |
System.out.print("nhap vao diem: "); | |
this.diem = inp.nextInt(); | |
inp.hasNextLine(); | |
} | |
protected void xuatThongTinSV() | |
{ | |
System.out.println("Thong tin sinh vien : "); | |
System.out.println(" Ho va ten: "+this.hoVaTen); | |
System.out.println(" Tuoi: "+this.tuoi); | |
System.out.println("Dia chi: "+this.diaChi); | |
System.out.println("So dien thoai : "+this.soDienThoai); | |
System.out.println("Dia chi email: "+this.Email); | |
System.out.println("Diem : "+this.diem); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment