-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPY04006
47 lines (40 loc) · 1.44 KB
/
PY04006
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
j04006/Main.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package j04006;
import java.util.*;
import java.text.*;
import java.time.*;
public class Main {
public static void main(String[] args) throws ParseException{
Scanner in = new Scanner(System.in);
SinhVien sv=new SinhVien(in.nextLine(),in.nextLine(),in.nextLine(),in.nextFloat());
System.out.println(sv);
}
}
j04006/SinhVien.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package j04006;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class SinhVien {
private String name, lop,ma;
private Date ngaysinh;
private float gpa;
public SinhVien(String name, String lop, String ngaysinh, float gpa) throws ParseException{
this.ma = "B20DCCN001";
this.name = name;
this.lop = lop;
this.ngaysinh = new SimpleDateFormat("dd/mm/yyyy").parse(ngaysinh);
this.gpa = gpa;
}
public String toString(){
return ma + " " + name + " " + lop + " " + new SimpleDateFormat("dd/mm/yyyy").format(ngaysinh) + " " + String.format("%.2f",gpa);
}
}