-
Notifications
You must be signed in to change notification settings - Fork 1
/
KhaiBaoLopSinhVien.java
94 lines (76 loc) · 2.02 KB
/
KhaiBaoLopSinhVien.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* 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 codeptit;
/**
*
* @author Administrator
*/
import java.util.Scanner;
class SinhVien {
private String msv;
private String hoTen;
private String lop;
private String ngaySinh;
private double gpa;
public SinhVien() {
}
public String getMsv() {
return msv;
}
public void setMsv(String msv) {
this.msv = msv;
}
public String getHoTen() {
return hoTen;
}
public String getLop() {
return lop;
}
public String getNgaySinh() {
return ngaySinh;
}
public double getGpa() {
return gpa;
}
public void setHoTen(String hoTen) {
this.hoTen = hoTen;
}
public void setLop(String lop) {
this.lop = lop;
}
public void setNgaySinh(String ngaySinh) {
this.ngaySinh = ngaySinh;
}
public void setGpa(double gpa) {
this.gpa = gpa;
}
@Override
public String toString() {
return this.msv + " " + this.hoTen + " " + this.lop + " " + this.ngaySinh + " " + String.format("%.2f", this.gpa);
}
public static String conv(String s) {
StringBuilder sb = new StringBuilder(s);
if(sb.charAt(1) == '/')
sb.insert(0, "0");
if(sb.charAt(4) == '/')
sb.insert(3, "0");
return sb.toString();
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
SinhVien sv = new SinhVien();
String hoTen = sc.nextLine();
String lop = sc.nextLine();
String ngaySinh = sc.nextLine();
double gpa = sc.nextDouble();
String ns = conv(ngaySinh);
sv.setMsv("B20DCCN001");
sv.setHoTen(hoTen);
sv.setLop(lop);
sv.setNgaySinh(ns);
sv.setGpa(gpa);
System.out.println(sv);
}
}