Beruflich Dokumente
Kultur Dokumente
this();
import java.util.Date; }
import java.util.Calendar;
soDu += soTien;
}
}
class TaiKhoan{
}
protected int soTK =0;
class TaiKhoanSec extends TaiKhoan{
protected double soDu =0, laiSuatNam =0.0;
private double chiTroi;
private Date ngayTao;
public TaiKhoanSec(int soTK, double soDu){
public TaiKhoan(){
super(soTK, soDu);
ngayTao = new Date();
}
}
public void setchiTroi(double chiTroi){
this.chiTroi = chiTroi;
public String getNgayTao() {
}
SimpleDateFormat df = new
public void rutTien(double soTien){
SimpleDateFormat("dd/MM/yyyy");
if(soTien <= soDu + chiTroi)
return df.format(ngayTao);
super.ruttien(soTien);
}
else arr.add(new
NhanVienCongNhat("Nguyen Van A",
System.out.print("Số tiền rút 123,210000.0));
vượt mức quy định! "); arr.add(new NhanVienLamGio("Le Thi
B", 456 ,60000.0, 50.0));
} for(nhanviennn i : arr)
if(i instanceof
public String toString(){ NhanVienCongNhat)
System.out.println("
String t = String.format("%.2f", soDu); Nhan vien cong nhat: \n "+ i);
else
double tienlai = super.tienLaiThang();
System.out.println("Nhan vien lam gio:
if(tienlai <0) \n "+ i);
for ( int i=0; i < arr.size();i++)
t+="\n Tra lai cho ngan hang: " + System.out.printf("Nhan
String.format("%.2f", -tienlai); vien [%d] thuoc lop %s", i,
arr.get(i).getClass().getName());
else
}
} System.out.println("Nhập độ dài cạnh:
");
BTC3_Cau2
canh =
sc.nextDouble();
HinhVuong hv = new
HinhVuong(canh);
hv.setTen("Hình }
Vuông");
hv.setX(x); public static void ShowMenu() {
hv.setY(y);
System.out.println("====================
System.out.println(hv); ==MENU=====================");
break; System.out.println("1. Hình Chữ
case 3: Nhật ");
System.out.println("2. Hình Vuông
System.out.print("Nhập tọa độ tâm (x, ");
y): "); System.out.println("3. Hình
x= sc.nextInt(); Ellipse ");
y= sc.nextInt(); System.out.println("4. Hình Tròn
");
System.out.println("5. Thoát");
System.out.println("Your choise
System.out.println("Nhập a, b: "); [1-5]: ");
a = sc.nextDouble(); System.out.println("--------------
b = sc.nextDouble(); ------------------------------------------");
Ellipse elip = new
Ellipse(a, b); }
elip.setTen("Hình
Ellipse"); }
elip.setX(x); class Hinh{
elip.setY(y); String ten;
int x, y;
System.out.println(elip);
break;
case 4: public void setTen(String ten) {
this.ten = ten;
System.out.print("Nhập tọa độ tâm (x, }
y): ");
x= sc.nextInt();
y= sc.nextInt(); public void setX(int x) {
this.x = x;
}
System.out.println("Nhập bán kính: ");
bk = sc.nextDouble();
HinhTron ht = new public void setY(int y) {
HinhTron(bk); this.y = y;
ht.setTen("Hình }
Tròn");
ht.setX(x);
ht.setY(y); public String toString() {
return ten +"\nTọa độ: " + "(" + x
System.out.println(ht); +(",") +y +(")\n");
break; }
case 5: }
default: class HinhChuNhat extends Hinh{
flag = false; double dai=0, rong=0;
break;
}
public double getDai() {
return dai;
}while(flag == true); }
public double getRong() { }
return rong; public String toString() {
} String str ="";
public HinhChuNhat(double dai, double if( a == b){
rong) { str = "Bán kính: " + a;
this.dai = dai; }
this.rong = rong; else {
} str = "Giá trị canh a:" + a
public double TinhDienTich() { + "\nGiá trị cạnh b: " + b ;
return dai * rong; }
} String t =
public double TinhChuVi() { String.format("%s%.2f%n", "\nDiện tích: "
return (dai + this.rong)*2; ,TinhDienTich());
} String v =
public String toString() { String.format("%s%.2f%n", "Chu vi: "
String str =""; ,TinhChuVi());
if( dai == rong){ return super.toString() + str + t
str = "Cạnh: " + dai; + v;
} }
else { }
str = "Dài: " + dai+ class HinhTron extends Ellipse{
"\nRộng:" + rong ; public HinhTron (double bk) {
} super(bk,bk);
String t = }
String.format("%s%.2f%n", "\nDiện tích: " }
,TinhDienTich()); Book_info
String v = package vd;
String.format("%s%.2f%n", "Chu vi: "
,TinhChuVi()); import java.util.Scanner;
return super.toString() + str + t
+ v; public class info_book {
} private static Book bookobj = null;
}
class HinhVuong extends HinhChuNhat{ public static void main(String[] args) {
public HinhVuong(double canh) { Scanner sc = new
super(canh, canh); Scanner(System.in);
} int functionID = 0;
} boolean flag = true;
class Ellipse extends Hinh{
double a,b; do {
ShowMenu();
public double getA() { functionID = sc.nextInt();
switch (functionID) {
return a; case 1: add();
} break;
public double getB() { case 2: edit();
return b; break;
} case 3: info();
public Ellipse(double a, double b) { break;
super(); case 4:
this.a = a; default:
this.b = b; flag = false;
} break;
public double TinhDienTich(){ }
return a*b *Math.PI; } while(flag == true);
}
} public static void ShowMenu() {
public double TinhChuVi(){ System.out.println("====================
return (a+b)*Math.PI; ==BOOK MANAGER=====================");
System.out.println("1. Add book "); }
System.out.println("2. Edit book "); }
System.out.println("3. Info book ");
System.out.println("4. Exit "); class Book{
System.out.println("Your choise [1-4]: private String ID;
"); private String name;
System.out.println("-------------------- private double price;
------------------------------------"); public Book(String iD, String name,
double price) {
} ID = iD;
public static void add() { this.name = name;
Scanner sc = new Scanner(System.in); this.price = price;
String bookName = ""; }
String bookID = ""; public String getID() {
double bookprice = 0; return ID;
System.out.println("ID : "); }
bookID = sc.next(); public void setID(String iD) {
System.out.println("Book name : "); ID = iD;
bookName = sc.next(); }
System.out.println("Book price : "); public String getName() {
bookprice = sc.nextDouble(); return name;
bookobj = new Book(bookID, bookName, }
bookprice); public void setName(String name) {
this.name = name;
} }
public static void edit() { public double getPrice() {
if(bookobj != null) { return price;
Scanner sc = new }
Scanner(System.in); public void setPrice(double price) {
String bookName = ""; this.price = price;
double bookprice = 0; }
System.out.println("Book name : public void Showinfo() {
"); System.out.println("Book Info :
bookName = sc.next(); ");
System.out.println("Book price : System.out.println("- ID \t\t: " +
"); this.getID());
bookprice = sc.nextDouble(); System.out.println("- Book Name
bookobj.setName(bookName); \t: " + this.getName());
bookobj.setPrice(bookprice); System.out.println("- Price \t: "
} + this.getPrice());
else
{ }
System.out.println("Chưa nhập
thông tin!!!"); }
} PhanSo
}
public static void info() { package vd;
if(bookobj != null) { import java.util.Scanner;
bookobj.Showinfo();
} public class Vdd_PhanSo {
else
{ public static void main(String[] args) {
System.out.println("Chưa nhập Scanner sc = new
thông tin!!!"); Scanner(System.in);
} int tu1, tu2, mau1, mau2;
String pheptinh;
} System.out.print("Nhập tử số phân
public static void exit() { số thứ nhất: ");
System.out.println("info_book.exit()"); tu1 = sc.nextInt();
do { case "-":
System.out.print("Nhập mẫu this.sub(fractionA,
số phân số thứ nhất: "); fractionB);
mau1 = sc.nextInt(); break;
} while ( mau1 == 0); case "x":
case "X":
System.out.print("Nhập tử số phân case "*":
số thứ hai: "); case ".":
tu2 = sc.nextInt(); this.multiply(fractionA,
do { fractionB);
System.out.print("Nhập mẫu break;
số phân số thứ hai: "); case ":":
mau2 = sc.nextInt(); case "/":
} while ( mau2 == 0); this.divide(fractionA,
System.out.print("Nhập phép tính: fractionB);
"); break;
pheptinh = sc.next(); }
this.denomirator=fractionA.getDenomirato }
r()*fractionB.getNumerator(); class Nguoi{
this.ToiGian(); private String hoten, sdt, dc;
} private Date birthday;
//UCLN SimpleDateFormat df = new
private int UCLN (int a, int b) { SimpleDateFormat("dd/MM/yyyy");
int r; public Nguoi(String hoten, String sdt,
while (b>0) { String dc, String birthday) {
r = a % b; this.hoten = hoten;
a = b; this.sdt = sdt;
b = r; this.dc = dc;
try {
} this.birthday =
Return df.parse(birthday);
a; }
public void ToiGian() { catch(ParseException e) {
int usc =
this.UCLN(this.getNumerator(),this.getDenomirat }
or()); }
this.numerator = public String toString() {
this.getNumerator() /usc; return "Họ và tên: " + hoten +
this.denomirator = "\nĐịa chỉ: " + dc + "\nNgày Sinh: "+
this.getDenomirator() /usc; df.format(birthday) + "\nSố điện thoại: "+
} sdt;
}
} }
BTC3_Cau3 class SinhVien extends Nguoi{
private int sonamhoc;
public final static int NAMNHAT =1;
import java.text.ParseException; public final static int NAMHAI =2;
import java.text.SimpleDateFormat; public final static int NAMBAT =3;
import java.util.Date; public final static int NAMTU =4;
public SinhVien(String hoten, String
public class BTC3_Cau3 { sdt, String dc, String birthday, int sonamhoc)
{
public static void main(String[] args) { super(hoten, sdt,dc, birthday);
SinhVien sv = new SinhVien("Nguyễn this.sonamhoc = sonamhoc;
Văn A", "1111", "Nguyễn Kiệm", "32/12/1995", }
SinhVien.NAMTU); public String toString() {
System.out.println(sv); return super.toString() + "\nSố
System.out.println("-------------- năm học: " + sonamhoc;
----------------------"); }
NhanVienVanPhong nvvp = new
NhanVienVanPhong("Lê Thị B", "2222", "Quang }
Trung", "06/07/1970","VND", 4.75, 4.74*139000, class NhanVien extends Nguoi{
"Kế Toán"); private String donvi;
System.out.println(nvvp); private double hesoluong;
private double luong = hesoluong *
1390000;
public NhanVien(String hoten, String
sdt,String dc, String birthday, String donvi,
Double hesoluong, Double luong) {
super(hoten, sdt,dc, birthday);
this.donvi = donvi;
this.hesoluong = hesoluong;
this.luong = luong;
}
}
class NhanVienTapVu extends NhanVien{
private String Congviec;
public NhanVienTapVu(String hoten,
String sdt, String dc, String birthday, String
donvi, Double hesoluong,Double luong, String
Congviec) {
super(hoten, sdt, dc, birthday,
donvi, hesoluong, luong);
this.Congviec = Congviec;
}
public String toString() {
return super.toString() + "\nCông
việc: " + Congviec;
}