Trang 1 của 6 123 ... CuốiCuối
Kết quả 1 đến 10 của 55
  1. #1
    Ngày tham gia
    Sep 2014
    Bài viết
    0

    Bài 15: Phương thức setter và getter trong Java

    /* bài viết thuộc loạt bài hướng dẫn trong "khóa học lập trình java miễn phí"
    trên diễn đàn android.vn, bạn có thể vào đây đọc

    để hiểu hơn về khóa học và tham gia ngay cùng mọi người */



    android.vn/attachments/pd3n2-png.17728/" border="0" alt="" />


    ở bài 12 mình có viết chú ý 1 điều như này:



    thông thường để an toàn cho vùng dữ liệu của các đối tượng người ta tránh dùng tiền tố public, mà thường chọn tiền tố private để ngăn cản quyền truy cập đến vùng dữ liệu của một lớp từ các phương thức bên ngoài lớp đó.
    ở các ví dụ trước, các thuộc tính mình thường để public , chương trình chạy, nhưng đó không phải là cách ổn. nếu chuyển về private, mà bạn vẫn truy cập các thuộc tính như các bài ví dụ trước thì sẽ lỗi như này:





    vậy làm như nào để truy cập các thuộc tính của đối tượng để private?

    1, biến this

    đầu tiên bạn cần hiểu biến này là gì?
    biến this là một biến ẩn tồn tại trong tất cả các lớp trong ngôn ngữ java. một class trong java luôn tồn tại một biến this, biến this được sử dụng trong khi chạy và tham khảo đến bản thân lớp chứa nó.

    2, phương thức setter

    mục đích của phương thức setter là chúng ta dùng nó để truy cập vào thuộc tính của đối tượng và gán giá trị cho các thuộc tính của đối tượng! tên gọi, hay cách bạn đặt tên phương thức này là tùy bạn, nó cũng vẫn chạy nhưng theo style code lập trình viên thường làm thì nó sẽ thường là set....

    ví dụ 1:


    Mã nguồn PHP:
    [color=#000000]
    package javademoandroidvn[/color][color=#007700]; class [/color][color=#0000bb]hocsinh [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]float diemtb[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten1[/color][color=#007700]) { [/color][color=#ff8000]//hoten1 là biến cục bộ nhập vào, thường để trùng tên thuộc tính như các hàm setter phía dưới [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten1[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]void setdiemtb[/color][color=#007700]([/color][color=#0000bb]float diemtb[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]= [/color][color=#0000bb]diemtb[/color][color=#007700]; }} public class [/color][color=#0000bb]javademoandroidvn [/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]hocsinh a [/color][color=#007700]= new [/color][color=#0000bb]hocsinh[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#dd0000]"vu van t"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#dd0000]"at7a"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setdiemtb[/color][color=#007700]([/color][color=#0000bb]7.5f[/color][color=#007700]); }}[/color] 
    2, phương thức getter

    cũng tương tự như phương thức setter, nó cũng dùng để truy cập vào các thuộc tính
    của đối tượng, nhưng ngược lại setter, phương thức getter sẽ trả về các thuộc tính của đối tượng!

    ví dụ 2:


    Mã nguồn PHP:
    [color=#000000]
    package javademoandroidvn[/color][color=#007700]; class [/color][color=#0000bb]hocsinh [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]float diemtb[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten1[/color][color=#007700]) { [/color][color=#ff8000]//hoten1 là biến cục bộ nhập vào, thường để trùng tên thuộc tính như các hàm setter phía dưới [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten1[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]string getlop[/color][color=#007700]() { return [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]float getdiemtb[/color][color=#007700]() { return [/color][color=#0000bb]diemtb[/color][color=#007700]; } public [/color][color=#0000bb]void setdiemtb[/color][color=#007700]([/color][color=#0000bb]float diemtb[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]= [/color][color=#0000bb]diemtb[/color][color=#007700]; }} public class [/color][color=#0000bb]javademoandroidvn [/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]hocsinh a [/color][color=#007700]= new [/color][color=#0000bb]hocsinh[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#dd0000]"vu van t"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#dd0000]"at7a"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setdiemtb[/color][color=#007700]([/color][color=#0000bb]7.5f[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"họ tên: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"lớp: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getlop[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"điểm tb: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdiemtb[/color][color=#007700]()); }}[/color] 
    các bạn nên xem video sau của blog studyandshare để hiểu hơn!
    3, cách tự chèn các phương thức getter và setter:

    khi bạn mới code java thì chưa nên dùng cách này, thực sự hiểu getter và setter rồi thì mới nên dùng.
    ở cả 2 ide phổ biến đều hỗ trợ tự chèn các phương thức getter và setter. với những bài khi khai báo nhiều biến, dùng tính năng này sẽ rất tiện!

    với netbeans:
    bạn nháy chuột phải lên vị trí soạn thảo code, chọn insert code
    sau đó sẽ hiện ra 1 menu nhỏ, bạn chọn getter, setter hoặc getter and setter tùy mục đích bạn dùng!
    bạn sẽ thấy netbeans tự sinh code cho các phương thức đó!





    với eclipese:
    bạn vào source --> generate getter and setter rồi chọn biến cần tạo phương
    thức getter và setter là được!







    bài tập về nhà::d

    bài 1: tạo package nhân sự, trong có 2 class là sinh viên và giảng viên
    class sinh viên gồm các thuộc tính: họ tên, lớp học, điểm toán, lý, hóa.
    class giảng viên gồm các thuộc tính: họ tên, lớp dạy, năm sinh, lương.
    tạo đối tượng học sinh a.
    tạo đối tượng giảng viên b.
    các giá trị của thuộc tính a và b nhập vào từ bàn phím.
    xử lý dữ liệu báo ra thông tin của a và b, tính và báo ra điểm trung bình của a,
    xếp loại học lực, báo b có dạy a hay không!
    các thuộc tính để private, sử dụng phương thức getter, setter.
    lập trình hướng đối tượng!

    (chú ý: các bạn nên tự giác làm bài tập, hoàn thiện rồi đăng lên, các bài bạn đã làm, nên để code trong thẻ code - chọn thẻ php cho rõ ràng và để ẩn code trong thẻ ẩn spoiler, để khi click vào mới hiện code lên , trước khi thử sức tự làm, bạn không nên nhìn code của các bạn khác đã đăng nhé)


    my facebook: https://www.facebook.com/tiasangmoi​
    bài viết đăng lên diễn đàn khác vui lòng ghi rõ nguồn: android.vn

  2. #2
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    3 class trong gói nhansu của mình:
    class sinhvien:
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package nhansu[/color][color=#007700]; class [/color][color=#0000bb]sinhvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lophoc[/color][color=#007700]; private [/color][color=#0000bb]float toan[/color][color=#007700],[/color][color=#0000bb]ly[/color][color=#007700],[/color][color=#0000bb]hoa[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten[/color][color=#007700]=[/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void setlophoc[/color][color=#007700]([/color][color=#0000bb]string lophoc[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lophoc[/color][color=#007700]=[/color][color=#0000bb]lophoc[/color][color=#007700]; } public [/color][color=#0000bb]string getlophoc[/color][color=#007700]() { return [/color][color=#0000bb]lophoc[/color][color=#007700]; } public [/color][color=#0000bb]void settoan[/color][color=#007700]([/color][color=#0000bb]float toan[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]toan[/color][color=#007700]=[/color][color=#0000bb]toan[/color][color=#007700]; } public [/color][color=#0000bb]float gettoan[/color][color=#007700]() { return [/color][color=#0000bb]toan[/color][color=#007700]; } public [/color][color=#0000bb]void setly[/color][color=#007700]([/color][color=#0000bb]float ly[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]ly[/color][color=#007700]=[/color][color=#0000bb]ly[/color][color=#007700]; } public [/color][color=#0000bb]float getly[/color][color=#007700]() { return [/color][color=#0000bb]ly[/color][color=#007700]; } public [/color][color=#0000bb]void sethoa[/color][color=#007700]([/color][color=#0000bb]float hoa[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoa[/color][color=#007700]=[/color][color=#0000bb]hoa[/color][color=#007700]; } public [/color][color=#0000bb]float gethoa[/color][color=#007700]() { return [/color][color=#0000bb]hoa[/color][color=#007700]; }}[/color] 
    </blockquote></div>
    </div>
    </div>

    class giangvien:
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package nhansu[/color][color=#007700]; class [/color][color=#0000bb]giangvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lopday[/color][color=#007700]; private [/color][color=#0000bb]long namsinh[/color][color=#007700]; private [/color][color=#0000bb]long luong[/color][color=#007700]; public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]string getlopday[/color][color=#007700]() { return [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]void setlopday[/color][color=#007700]([/color][color=#0000bb]string lopday[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lopday [/color][color=#007700]= [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]long getnamsinh[/color][color=#007700]() { return [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]void setnamsinh[/color][color=#007700]([/color][color=#0000bb]long namsinh[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]long getluong[/color][color=#007700]() { return [/color][color=#0000bb]luong[/color][color=#007700]; } public [/color][color=#0000bb]void setluong[/color][color=#007700]([/color][color=#0000bb]long luong[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]luong [/color][color=#007700]= [/color][color=#0000bb]luong[/color][color=#007700]; }}[/color] 
    </blockquote></div>
    </div>
    </div>

    class qlnhansu (main class để chạy)
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; public class [/color][color=#0000bb]qlnhansu [/color][color=#007700]{ public static [/color][color=#0000bb]string xeploai[/color][color=#007700]([/color][color=#0000bb]float dtb[/color][color=#007700]) { if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]8.0[/color][color=#007700]) { return [/color][color=#dd0000]"giỏi"[/color][color=#007700]; } else if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]6.5[/color][color=#007700]) { return [/color][color=#dd0000]"khá"[/color][color=#007700]; } else if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]5.0[/color][color=#007700]) { return [/color][color=#dd0000]"trung bình"[/color][color=#007700]; } else { return [/color][color=#dd0000]"yếu"[/color][color=#007700]; } } public static [/color][color=#0000bb]boolean coday[/color][color=#007700]([/color][color=#0000bb]string lop1[/color][color=#007700], [/color][color=#0000bb]string lop2[/color][color=#007700]) { if ([/color][color=#0000bb]lop1[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]lop2[/color][color=#007700])) { return [/color][color=#0000bb]true[/color][color=#007700]; } else { return [/color][color=#0000bb]false[/color][color=#007700]; } } public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#ff8000]// nhap du lieu cua sv a [/color][color=#0000bb]sinhvien a [/color][color=#007700]= new [/color][color=#0000bb]sinhvien[/color][color=#007700](); [/color][color=#0000bb]giangvien b [/color][color=#007700]= new [/color][color=#0000bb]giangvien[/color][color=#007700](); [/color][color=#0000bb]scanner nhapdulieu [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ tên của sinh viên a: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập lớp học của sinh viên a: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setlophoc[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập điểm toán: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]settoan[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập điểm lý: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setly[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập điểm hóa: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoa[/color][color=#007700]([/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]float dtb [/color][color=#007700]= ([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gettoan[/color][color=#007700]() + [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getly[/color][color=#007700]() + [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoa[/color][color=#007700]()) / [/color][color=#0000bb]3[/color][color=#007700]; [/color][color=#ff8000]// nhap du lieu cua gv b [/color][color=#0000bb]scanner nhapdulieu2 [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ tên giảng viên b: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]nhapdulieu2[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập lớp dạy của giảng viên b: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setlopday[/color][color=#007700]([/color][color=#0000bb]nhapdulieu2[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập năm sinh của giảng viên b: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setnamsinh[/color][color=#007700]([/color][color=#0000bb]nhapdulieu2[/color][color=#007700].[/color][color=#0000bb]nextlong[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập lương của giảng viên b: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setluong[/color][color=#007700]([/color][color=#0000bb]nhapdulieu2[/color][color=#007700].[/color][color=#0000bb]nextlong[/color][color=#007700]()); [/color][color=#ff8000]// xuat [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"sv a: họ tên: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()+[/color][color=#dd0000]" lớp "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getlophoc[/color][color=#007700]()+[/color][color=#dd0000]" điểm trung bình "[/color][color=#007700]+[/color][color=#0000bb]dtb[/color][color=#007700]+[/color][color=#dd0000]" xếp loại "[/color][color=#007700]+[/color][color=#0000bb]xeploai[/color][color=#007700]([/color][color=#0000bb]dtb[/color][color=#007700])); if ([/color][color=#0000bb]coday[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getlophoc[/color][color=#007700](),[/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]getlopday[/color][color=#007700]())) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"giảng viên b có dạy sinh viên a"[/color][color=#007700]); } else { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"giảng viên b không dạy sinh viên a"[/color][color=#007700]); } }}[/color] 
    </blockquote></div>
    </div>
    </div>

    export gói nhansu: nhansu.zip (file đính kèm)

  3. #3
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    quagn1998: bạn cần để phương thức điểm trung bình và xếp loại trong class sinh viên, vì nó liên quan tới các đối tượng sinh viên :d

  4. #4
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    lười tạo package mới, a thông cảm, :d
    class sinhviên
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package demojava[/color][color=#007700].[/color][color=#0000bb]android[/color][color=#007700].[/color][color=#0000bb]vn[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; public class [/color][color=#0000bb]unit15_sinhvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]float dtoan[/color][color=#007700], [/color][color=#0000bb]dly[/color][color=#007700], [/color][color=#0000bb]dhoa[/color][color=#007700]; public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]string getlop[/color][color=#007700]() { return [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]float getdtoan[/color][color=#007700]() { return [/color][color=#0000bb]dtoan[/color][color=#007700]; } public [/color][color=#0000bb]void setdtoan[/color][color=#007700]([/color][color=#0000bb]float dtoan[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dtoan [/color][color=#007700]= [/color][color=#0000bb]dtoan[/color][color=#007700]; } public [/color][color=#0000bb]float getdly[/color][color=#007700]() { return [/color][color=#0000bb]dly[/color][color=#007700]; } public [/color][color=#0000bb]void setdly[/color][color=#007700]([/color][color=#0000bb]float dly[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dly [/color][color=#007700]= [/color][color=#0000bb]dly[/color][color=#007700]; } public [/color][color=#0000bb]float getdhoa[/color][color=#007700]() { return [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]void setdhoa[/color][color=#007700]([/color][color=#0000bb]float dhoa[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dhoa [/color][color=#007700]= [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]float dtb[/color][color=#007700]([/color][color=#0000bb]float dtoan[/color][color=#007700], [/color][color=#0000bb]float dly[/color][color=#007700], [/color][color=#0000bb]float dhoa[/color][color=#007700]){ return ([/color][color=#0000bb]getdtoan[/color][color=#007700]() + [/color][color=#0000bb]getdly[/color][color=#007700]()+[/color][color=#0000bb]getdhoa[/color][color=#007700]())/[/color][color=#0000bb]3[/color][color=#007700]; } public [/color][color=#0000bb]void input[/color][color=#007700]() { [/color][color=#0000bb]scanner inp [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập thông tin sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ và tên: "[/color][color=#007700]); [/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" lớp: "[/color][color=#007700]); [/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" điểm toán, lý, hoá: "[/color][color=#007700]); [/color][color=#0000bb]setdtoan[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]setdly[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]setdhoa[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } public [/color][color=#0000bb]string hocluc[/color][color=#007700]([/color][color=#0000bb]float dtb[/color][color=#007700]){ if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]8.0[/color][color=#007700]) { return [/color][color=#dd0000]"giỏi"[/color][color=#007700]; } else if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]6.5[/color][color=#007700]) { return [/color][color=#dd0000]"khá"[/color][color=#007700]; } else if ([/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]5.0[/color][color=#007700]) { return [/color][color=#dd0000]"trung bình"[/color][color=#007700]; } else { return [/color][color=#dd0000]"yếu"[/color][color=#007700]; } } public [/color][color=#0000bb]void output[/color][color=#007700](){ [/color][color=#0000bb]float dtb [/color][color=#007700]= [/color][color=#0000bb]dtb[/color][color=#007700]([/color][color=#0000bb]getdtoan[/color][color=#007700](), [/color][color=#0000bb]getdly[/color][color=#007700](), [/color][color=#0000bb]getdhoa[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"thông tin sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"họ tên "[/color][color=#007700]+[/color][color=#0000bb]gethoten[/color][color=#007700]()+[/color][color=#dd0000]" lớp: "[/color][color=#007700]+[/color][color=#0000bb]getlop[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]( [/color][color=#dd0000]" điểm trung bình: "[/color][color=#007700]+[/color][color=#0000bb]dtb[/color][color=#007700]+[/color][color=#dd0000]" xếp loại: "[/color][color=#007700]+[/color][color=#0000bb]hocluc[/color][color=#007700]([/color][color=#0000bb]dtb[/color][color=#007700])); }}[/color] 
    </blockquote></div>
    </div>
    </div>

    class giangvien
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package demojava[/color][color=#007700].[/color][color=#0000bb]android[/color][color=#007700].[/color][color=#0000bb]vn[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; public class [/color][color=#0000bb]unit15_giangvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]int namsinh[/color][color=#007700]; private [/color][color=#0000bb]long luong[/color][color=#007700]; public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]string getlop[/color][color=#007700]() { return [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]int getnamsinh[/color][color=#007700]() { return [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]void setnamsinh[/color][color=#007700]([/color][color=#0000bb]int namsinh[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]long getluong[/color][color=#007700]() { return [/color][color=#0000bb]luong[/color][color=#007700]; } public [/color][color=#0000bb]void setluong[/color][color=#007700]([/color][color=#0000bb]long luong[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]luong [/color][color=#007700]= [/color][color=#0000bb]luong[/color][color=#007700]; } public [/color][color=#0000bb]void input[/color][color=#007700]() { [/color][color=#0000bb]scanner inp [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập thông tin giảng viên: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ và tên: "[/color][color=#007700]); [/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" lớp: "[/color][color=#007700]); [/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" năm sinh: "[/color][color=#007700]); [/color][color=#0000bb]setnamsinh[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" lương của giảng viên: "[/color][color=#007700]); [/color][color=#0000bb]setluong[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextlong[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); } public [/color][color=#0000bb]void output[/color][color=#007700](){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"thông tin giảng viên: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"họ tên: "[/color][color=#007700]+[/color][color=#0000bb]gethoten[/color][color=#007700]()+[/color][color=#dd0000]" lớp: "[/color][color=#007700]+[/color][color=#0000bb]getlop[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" năm sinh: "[/color][color=#007700]+[/color][color=#0000bb]getnamsinh[/color][color=#007700]()+[/color][color=#dd0000]" lương: "[/color][color=#007700]+[/color][color=#0000bb]getluong[/color][color=#007700]()); }}[/color] 
    </blockquote></div>
    </div>
    </div>

    class main

    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    package demojava[/color][color=#007700].[/color][color=#0000bb]android[/color][color=#007700].[/color][color=#0000bb]vn[/color][color=#007700]; public class [/color][color=#0000bb]unit15_main [/color][color=#007700]{ public [/color][color=#0000bb]int test[/color][color=#007700]([/color][color=#0000bb]string sv[/color][color=#007700], [/color][color=#0000bb]string gv[/color][color=#007700]){ if ([/color][color=#0000bb]sv[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]gv[/color][color=#007700])) return [/color][color=#0000bb]1[/color][color=#007700]; else return [/color][color=#0000bb]0[/color][color=#007700]; } public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]unit15_main test [/color][color=#007700]= new [/color][color=#0000bb]unit15_main[/color][color=#007700](); [/color][color=#0000bb]unit15_sinhvien svien [/color][color=#007700]= new [/color][color=#0000bb]unit15_sinhvien[/color][color=#007700](); [/color][color=#0000bb]unit15_giangvien gvien [/color][color=#007700]= new [/color][color=#0000bb]unit15_giangvien[/color][color=#007700](); [/color][color=#ff8000]//input [/color][color=#0000bb]svien[/color][color=#007700].[/color][color=#0000bb]input[/color][color=#007700](); [/color][color=#0000bb]gvien[/color][color=#007700].[/color][color=#0000bb]input[/color][color=#007700](); [/color][color=#ff8000]//output [/color][color=#0000bb]svien[/color][color=#007700].[/color][color=#0000bb]output[/color][color=#007700](); [/color][color=#0000bb]gvien[/color][color=#007700].[/color][color=#0000bb]output[/color][color=#007700](); [/color][color=#ff8000]//compare [/color][color=#0000bb]int kt [/color][color=#007700]= [/color][color=#0000bb]test[/color][color=#007700].[/color][color=#0000bb]test[/color][color=#007700]([/color][color=#0000bb]svien[/color][color=#007700].[/color][color=#0000bb]getlop[/color][color=#007700](),[/color][color=#0000bb]gvien[/color][color=#007700].[/color][color=#0000bb]getlop[/color][color=#007700]()); if ([/color][color=#0000bb]kt[/color][color=#007700]==[/color][color=#0000bb]1[/color][color=#007700]) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"giảng viên "[/color][color=#007700]+[/color][color=#0000bb]gvien[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()+[/color][color=#dd0000]" dạy sinh viên "[/color][color=#007700]+[/color][color=#0000bb]svien[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()); else [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"giảng viên "[/color][color=#007700]+[/color][color=#0000bb]gvien[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()+[/color][color=#dd0000]" không dạy sinh viên "[/color][color=#007700]+[/color][color=#0000bb]svien[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  5. #5
    Ngày tham gia
    May 2014
    Bài viết
    0
    cho t hỏi chút
    system.out.print("điểm toán, lý, hoá: ");
    a.settlh(nhap.nextdouble(), nhap.nextdouble(), nhap.nextdouble() );
    khi t nhập là 9 9 9 enter thì máy k báo lỗi
    mà khi t nhập số thực như 5.5 5.1 5.2 enter thì máy lại báo lỗi
    // là sao nhỉ ???

  6. #6
    Ngày tham gia
    Mar 2014
    Bài viết
    0
    Trích dẫn Gửi bởi diepthanh94
    cho t hỏi chút
    system.out.print("điểm toán, lý, hoá: ");
    a.settlh(nhap.nextdouble(), nhap.nextdouble(), nhap.nextdouble() );
    khi t nhập là 9 9 9 enter thì máy k báo lỗi
    mà khi t nhập số thực như 5.5 5.1 5.2 enter thì máy lại báo lỗi
    // là sao nhỉ ???
    up code lên anh em xem , có thể sửa lại nhập từng cái 1 xem sao!

  7. #7
    Ngày tham gia
    Apr 2014
    Bài viết
    0
    //em mới ccode tới đây thôi

    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700];class [/color][color=#0000bb]sinhvien[/color][color=#007700]{ private [/color][color=#0000bb]string hoten_sv[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]double dtoan[/color][color=#007700]; private [/color][color=#0000bb]double dly[/color][color=#007700]; private [/color][color=#0000bb]double dhoa[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten_sv [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]void settlh[/color][color=#007700]([/color][color=#0000bb]double dtoan[/color][color=#007700], [/color][color=#0000bb]double dly[/color][color=#007700], [/color][color=#0000bb]double dhoa[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dtoan [/color][color=#007700]=[/color][color=#0000bb]dtoan[/color][color=#007700]; [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dly [/color][color=#007700]= [/color][color=#0000bb]dly[/color][color=#007700]; [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dhoa [/color][color=#007700]= [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700](){ return [/color][color=#0000bb]hoten_sv[/color][color=#007700]; } public [/color][color=#0000bb]string getlop[/color][color=#007700](){ return [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]double gettoan[/color][color=#007700](){ return [/color][color=#0000bb]dtoan[/color][color=#007700]; } public [/color][color=#0000bb]double getly[/color][color=#007700](){ return [/color][color=#0000bb]dly[/color][color=#007700]; } public [/color][color=#0000bb]double gethoa[/color][color=#007700](){ return [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]double getdtb[/color][color=#007700](){ return ([/color][color=#0000bb]dtoan[/color][color=#007700]+[/color][color=#0000bb]dly[/color][color=#007700]+[/color][color=#0000bb]dhoa[/color][color=#007700])/[/color][color=#0000bb]3[/color][color=#007700]; } }class [/color][color=#0000bb]giangvien[/color][color=#007700]{ private [/color][color=#0000bb]string hoten_gv[/color][color=#007700]; private [/color][color=#0000bb]string lopday[/color][color=#007700]; private [/color][color=#0000bb]int namsinh[/color][color=#007700]; private [/color][color=#0000bb]double luong[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten1[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten_gv [/color][color=#007700]= [/color][color=#0000bb]hoten1[/color][color=#007700]; } public [/color][color=#0000bb]void setlopday[/color][color=#007700]([/color][color=#0000bb]string lopday[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lopday [/color][color=#007700]= [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]void setnamsinh[/color][color=#007700]([/color][color=#0000bb]int namsinh[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]void setluong[/color][color=#007700]([/color][color=#0000bb]double luong[/color][color=#007700]){ [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]luong [/color][color=#007700]= [/color][color=#0000bb]luong[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700](){ return [/color][color=#0000bb]hoten_gv[/color][color=#007700]; } public [/color][color=#0000bb]string getlopday[/color][color=#007700](){ return [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]int getnamsinh[/color][color=#007700](){ return [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]double getluong[/color][color=#007700](){ return [/color][color=#0000bb]luong[/color][color=#007700]; }}public class [/color][color=#0000bb]bai9_2 [/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]scanner nhap [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]sinhvien a [/color][color=#007700]= new [/color][color=#0000bb]sinhvien[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập tên sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]( [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"lớp: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"điểm toán, lý, hoá: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]settlh[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700](), [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700](), [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"..."[/color][color=#007700]); [/color][color=#0000bb]giangvien b [/color][color=#007700]= new [/color][color=#0000bb]giangvien[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"tên giảng viên: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]( [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"lớp dạy: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setlopday[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"năm sinh: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setnamsinh[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"lương: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setluong[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]() ); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"thông tin về sinh viên:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" tên: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" lớp: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getlop[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" điểm toán, lý, hoá : "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gettoan[/color][color=#007700]()+ [/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getly[/color][color=#007700]()+[/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoa[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" điểm trung bình: "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" xếp loại: "[/color][color=#007700]); if ([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()<[/color][color=#0000bb]5.0[/color][color=#007700]) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"yếu."[/color][color=#007700]); if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()>= [/color][color=#0000bb]5.0[/color][color=#007700])&&([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()<[/color][color=#0000bb]6.5[/color][color=#007700])) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"trung bình."[/color][color=#007700]); if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()>=[/color][color=#0000bb]6.5[/color][color=#007700])&&[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()<[/color][color=#0000bb]8.0[/color][color=#007700]) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"khá."[/color][color=#007700]); if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()>[/color][color=#0000bb]8[/color][color=#007700])) [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"giỏi."[/color][color=#007700]); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  8. #8
    Ngày tham gia
    Jan 2015
    Bài viết
    0
    diepthanh94 anh đã thử và không có lỗi , em thử xem lại xem, không chắc có sai code:

    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>spoiler (move your mouse to the spoiler area to reveal the content)</noscript>

    show spoiler
    hide spoiler

    </div>
    <div class="quotecontent">
    <div class="bbcm_spoiler_noscript"><blockquote>


    Mã nguồn PHP:
    [color=#000000]
    [/color][color=#ff8000]/** to change this template, choose tools | templates* and open the template in the editor.*/[/color][color=#0000bb]package javaapplication6[/color][color=#007700]; [/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]scanner[/color][color=#007700]; class [/color][color=#0000bb]sinhvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten_sv[/color][color=#007700]; private [/color][color=#0000bb]string lop[/color][color=#007700]; private [/color][color=#0000bb]double dtoan[/color][color=#007700]; private [/color][color=#0000bb]double dly[/color][color=#007700]; private [/color][color=#0000bb]double dhoa[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten_sv [/color][color=#007700]= [/color][color=#0000bb]hoten[/color][color=#007700]; } public [/color][color=#0000bb]void setlop[/color][color=#007700]([/color][color=#0000bb]string lop[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]void settlh[/color][color=#007700]([/color][color=#0000bb]double dtoan[/color][color=#007700], [/color][color=#0000bb]double dly[/color][color=#007700], [/color][color=#0000bb]double dhoa[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dtoan [/color][color=#007700]= [/color][color=#0000bb]dtoan[/color][color=#007700]; [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dly [/color][color=#007700]= [/color][color=#0000bb]dly[/color][color=#007700]; [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]dhoa [/color][color=#007700]= [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten_sv[/color][color=#007700]; } public [/color][color=#0000bb]string getlop[/color][color=#007700]() { return [/color][color=#0000bb]lop[/color][color=#007700]; } public [/color][color=#0000bb]double gettoan[/color][color=#007700]() { return [/color][color=#0000bb]dtoan[/color][color=#007700]; } public [/color][color=#0000bb]double getly[/color][color=#007700]() { return [/color][color=#0000bb]dly[/color][color=#007700]; } public [/color][color=#0000bb]double gethoa[/color][color=#007700]() { return [/color][color=#0000bb]dhoa[/color][color=#007700]; } public [/color][color=#0000bb]double getdtb[/color][color=#007700]() { return ([/color][color=#0000bb]dtoan [/color][color=#007700]+ [/color][color=#0000bb]dly [/color][color=#007700]+ [/color][color=#0000bb]dhoa[/color][color=#007700]) / [/color][color=#0000bb]3[/color][color=#007700]; }} class [/color][color=#0000bb]giangvien [/color][color=#007700]{ private [/color][color=#0000bb]string hoten_gv[/color][color=#007700]; private [/color][color=#0000bb]string lopday[/color][color=#007700]; private [/color][color=#0000bb]int namsinh[/color][color=#007700]; private [/color][color=#0000bb]double luong[/color][color=#007700]; public [/color][color=#0000bb]void sethoten[/color][color=#007700]([/color][color=#0000bb]string hoten1[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hoten_gv [/color][color=#007700]= [/color][color=#0000bb]hoten1[/color][color=#007700]; } public [/color][color=#0000bb]void setlopday[/color][color=#007700]([/color][color=#0000bb]string lopday[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]lopday [/color][color=#007700]= [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]void setnamsinh[/color][color=#007700]([/color][color=#0000bb]int namsinh[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]void setluong[/color][color=#007700]([/color][color=#0000bb]double luong[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]luong [/color][color=#007700]= [/color][color=#0000bb]luong[/color][color=#007700]; } public [/color][color=#0000bb]string gethoten[/color][color=#007700]() { return [/color][color=#0000bb]hoten_gv[/color][color=#007700]; } public [/color][color=#0000bb]string getlopday[/color][color=#007700]() { return [/color][color=#0000bb]lopday[/color][color=#007700]; } public [/color][color=#0000bb]int getnamsinh[/color][color=#007700]() { return [/color][color=#0000bb]namsinh[/color][color=#007700]; } public [/color][color=#0000bb]double getluong[/color][color=#007700]() { return [/color][color=#0000bb]luong[/color][color=#007700]; }} public class [/color][color=#0000bb]javaapplication6 [/color][color=#007700]{ [/color][color=#ff8000]/** * @param args the command line arguments */ [/color][color=#007700]public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]scanner nhap [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]sinhvien a [/color][color=#007700]= new [/color][color=#0000bb]sinhvien[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập tên sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"lớp: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]setlop[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"điểm toán, lý, hoá: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]settlh[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700](), [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700](), [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"..."[/color][color=#007700]); [/color][color=#0000bb]giangvien b [/color][color=#007700]= new [/color][color=#0000bb]giangvien[/color][color=#007700](); [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"tên giảng viên: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]sethoten[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"lớp dạy: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setlopday[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"năm sinh: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setnamsinh[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"lương: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]setluong[/color][color=#007700]([/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]""[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"thông tin về sinh viên:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" tên: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoten[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" lớp: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getlop[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" điểm toán, lý, hoá : "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gettoan[/color][color=#007700]() + [/color][color=#dd0000]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getly[/color][color=#007700]() + [/color][color=#dd0000]" " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gethoa[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]" điểm trung bình: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" xếp loại: "[/color][color=#007700]); if ([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() < [/color][color=#0000bb]5.0[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"yếu."[/color][color=#007700]); } if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() >= [/color][color=#0000bb]5.0[/color][color=#007700]) && ([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() < [/color][color=#0000bb]6.5[/color][color=#007700])) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"trung bình."[/color][color=#007700]); } if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() >= [/color][color=#0000bb]6.5[/color][color=#007700]) && [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() < [/color][color=#0000bb]8.0[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"khá."[/color][color=#007700]); } if (([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]getdtb[/color][color=#007700]() > [/color][color=#0000bb]8[/color][color=#007700])) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"giỏi."[/color][color=#007700]); } }}[/color] 
    </blockquote></div>
    </div>
    </div>

  9. #9
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    haizzzzzzzz chắc tại máy e r

  10. #10
    Ngày tham gia
    Oct 2014
    Bài viết
    0
    mạng lag nên bị 2 bài, ad thông cảm cho e :d

Trang 1 của 6 123 ... CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •