Trang 3 của 5 Đầu tiênĐầu tiên 12345 CuốiCuối
Kết quả 21 đến 30 của 49
  1. #21
    Ngày tham gia
    Jul 2014
    Bài viết
    0
    mình xin nộp bà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]svien[/color][color=#007700]{ public [/color][color=#0000bb]string hoten[/color][color=#007700]; public [/color][color=#0000bb]string lop[/color][color=#007700]; public [/color][color=#0000bb]float diemtb[/color][color=#007700];} public class [/color][color=#0000bb]bt1 [/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]svien a [/color][color=#007700]= new [/color][color=#0000bb]svien[/color][color=#007700](); [/color][color=#0000bb]svien b [/color][color=#007700]= new [/color][color=#0000bb]svien[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhap ten sinh vien 1: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]hoten [/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]"lop: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]lop [/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]"diem tb: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]= [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextfloat[/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]"nhap ten sinh vien 2: "[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]hoten [/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]"lop: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]lop [/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]"diem tb: "[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]= [/color][color=#0000bb]nhap[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); if([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]> [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtb[/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]"diem tb cua hoc sinh 1 cao hon - " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtb[/color][color=#007700]); }else if([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtb [/color][color=#007700]< [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtb[/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]"diem tb cua hoc sinh 2 cao hon - " [/color][color=#007700]+ [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtb[/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]"diem tb cua hai hoc sinh bang nhau"[/color][color=#007700]); } } }[/color] 
    </blockquote></div>
    </div>
    </div>

  2. #22
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    bài 1:
    <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=#007700]class [/color][color=#0000bb]hocsinh[/color][color=#007700]{ public [/color][color=#0000bb]string hoten[/color][color=#007700]; public [/color][color=#0000bb]string lop[/color][color=#007700]; public [/color][color=#0000bb]float diemtrungbinh[/color][color=#007700];}public class [/color][color=#0000bb]hs [/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]hocsinh b [/color][color=#007700]= new [/color][color=#0000bb]hocsinh[/color][color=#007700](); [/color][color=#0000bb]hocsinh c [/color][color=#007700]= new [/color][color=#0000bb]hocsinh[/color][color=#007700](); [/color][color=#0000bb]scanner input [/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]scanner input2 [/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]"nhap thong tin sinh vien a: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"ho ten:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]input[/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]"lop:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]input[/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]"diem trung binh:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtrungbinh [/color][color=#007700]= [/color][color=#0000bb]input[/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]"nhap thong tin sinh vien b: "[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"ho ten:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]hoten [/color][color=#007700]= [/color][color=#0000bb]input2[/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]"lop:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]lop [/color][color=#007700]= [/color][color=#0000bb]input2[/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]"diem trung binh:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtrungbinh [/color][color=#007700]= [/color][color=#0000bb]input2[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); if ( [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]diemtrungbinh [/color][color=#007700]>= [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]diemtrungbinh[/color][color=#007700]) [/color][color=#0000bb]c [/color][color=#007700]= [/color][color=#0000bb]a[/color][color=#007700]; else [/color][color=#0000bb]c [/color][color=#007700]= [/color][color=#0000bb]b[/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]"thong tin hoc sinh co diem cao hon!"[/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]"ho ten: " [/color][color=#007700]+ [/color][color=#0000bb]c[/color][color=#007700].[/color][color=#0000bb]hoten[/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]"lop: " [/color][color=#007700]+ [/color][color=#0000bb]c[/color][color=#007700].[/color][color=#0000bb]lop[/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]"diem trung binh: " [/color][color=#007700]+ [/color][color=#0000bb]c[/color][color=#007700].[/color][color=#0000bb]diemtrungbinh[/color][color=#007700]); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  3. #23
    Ngày tham gia
    Jun 2014
    Bài viết
    0
    Mã:
    /*
    * to change this license header, choose license headers in project properties.
    * to change this template file, choose tools | templates
    * and open the template in the editor.
    */
     
    package unit.pkg12;
     
    /**
    *
    * @author hoang phung
    */
     
    import java.util.scanner;
     
    class hocsinh{
       
        public string hoten;
        public float dtb;
        public string lop;
    }
     
    public class unit12 {
     
        /**
        * @param args the command line arguments
        */
        public static void main(string[] args) {
            scanner input = new scanner(system.in);
            hocsinh a = new hocsinh();
            system.out.println("nhap du lieu cho hoc sinh a:");
            system.out.print("ho va ten: "); a.hoten = input.nextline();
            system.out.print("diem trung binh: "); a.dtb = input.nextfloat();
            input.nextline();
            system.out.print("lop: "); a.lop = input.nextline();
            hocsinh b = new hocsinh();
            system.out.println("nhap du lieu cho hoc sinh b:");
            system.out.print("ho va ten: "); b.hoten = input.nextline();
            system.out.print("diem trung binh: "); b.dtb = input.nextfloat();
            input.nextline();
            system.out.print("lop: "); b.lop = input.nextline();
            if(a.dtb > b.dtb){
                system.out.println("hoc sinh a co diem cao hon hoc sinh b");
            }else{
                system.out.println("hoc sinh b co diem cao hon hoc sinh a");
            }
        }
       
    }
    <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></blockquote></div>
    </div>
    </div>

  4. #24
    Ngày tham gia
    Sep 2014
    Bài viết
    0
    hi all,

    mình vẫn thấy mơ hồ ở chỗ việc tạo class, nó tạo ra các thuộc tính cho 1 đối tượng, nhưng sau đó mình cũng phải gán giá trị cho các thuộc tính thuộc lo71o đó. như vậy, có khác gì mình tạo các đối tượng rồi gán giá trị, không cần tạo lớp.

    ví dụ:


    Mã:
    class concho {
     
        string ten ;
        string maulong ;
     
    }
     
    public class main {
     
        public static void main (string arg []){
         
            concho a = new concho ();
                a.ten = "ben" ;
                a.maulong = "do" ;
    }
    }
    có khác gì với việc gán thẳng giá trị ban đầu luôn ko cần tạo class chi mất công


    Mã:
    public class main {
     
        public static void main (string arg []){
         
         
                string a_ten = "ben" ;
                string a_maulong = "do" ;
    }
    }
    sự khác biệt giữa 2 đoạn code, công dụng của class, nó có giống hàm con trong c hay không ?

  5. #25
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    cuocdoi: hi bạn, class không phải là hàm con như trong c nhé. class có thể để định nghĩa một kiểu dữ liệu, ví dụ bạn cần quản lý danh sách sinh viên, mỗi sinh viên có nhiều thông tin: tên , tuổi, lớp, .v...v.v , thì khi lập trình, ta có thể sẽ phải thao tác với mảng các sinh viên gồm rất nhiều sinh viên. khi đó, mảng đó chứa nhiều phần tử có kiểu dữ liệu giống nhau, nó có nhiều thuộc tính, và việc tạo class sẽ định nghĩa được kiểu dữ liệu đối tượng sinh viên này, các kiểu dữ liệu thông thường không đủ định nghĩa!

    khi lập trình c, chắc chắn bạn đã làm bài tập liên quan tới việc quản lý mảng các bản ghi, thì class cũng gần như việc định nghĩa 1 bản ghi trong c, tuy nhiên, nó mạnh mẽ hơn ^^

  6. #26
    Ngày tham gia
    Sep 2014
    Bài viết
    0
    mong mấy bạn góp ý cho mình với nha , mình viết còn lung tung quá :d hk biết cách thiết kế, sắp sếp code sao cho hợp lý nữa :d

    <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ã:
    import java.util.scanner;
     
    class hocsinh {
     
        public string hoten, lop;
        public float dientrungbinh;
    }
     
    public class bai1 {
     
        public static void main(string[] args) {
            hocsinh a = new hocsinh();
            hocsinh b = new hocsinh();
            scanner input = new scanner(system.in);
           
            system.out.print("nhap ten hoc sinh a: ");
            a.hoten = input.nextline();
            system.out.print("nhap lop hoc sinh a: ");
            a.lop = input.nextline();
            system.out.println("nhap diem trung binh hoc sinh a: ");
            a.dientrungbinh = nhapdiem();
     
            system.out.print("nhap ten hoc sinh b: ");
            b.hoten = input.nextline();
            system.out.print("nhap lop hoc sinh b: ");
            b.lop = input.nextline();
            system.out.println("nhap diem trung binh hoc sinh b: ");
            b.dientrungbinh = nhapdiem();
     
            if (a.dientrungbinh > b.dientrungbinh) {
                system.out.println("hoc sinh \"" + a.hoten + "\" co diem trung binh cao hon hoc sinh \"" + b.hoten + "\"");
            } else if (a.dientrungbinh < b.dientrungbinh) {
                system.out.println("hoc sinh \"" + b.hoten + "\" co diem trung binh cao hon hoc sinh \"" + a.hoten + "\"");
            } else {
                system.out.println("diem trung binh cua 2 hoc sinh bang nhau!");
            }
        }
     
        public static float nhapdiem() {
            float n = 0;
            scanner input = new scanner(system.in);
            boolean check = true;
            while (check) {
                try {
                    n = input.nextfloat();
                    if (n >= 0 && n <= 10) {
                        check = false;
                    } else {
                        system.out.println("chi duoc nhap so tu 1-10, nhap lai!");
                        input.nextline();
                    }
                } catch (exception e) {
                    system.out.println("chi duoc nhap so, nhap lai!");
                    input.nextline();
                }
            }
            return n;
        }
    }
    </blockquote></div>
    </div>
    </div>

  7. #27
    Ngày tham gia
    Apr 2014
    Bài viết
    0
    bai lam cua minh:
    <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 javabasic[/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]hocsinh[/color][color=#007700]{ public [/color][color=#0000bb]string hoten[/color][color=#007700]; public [/color][color=#0000bb]string lop[/color][color=#007700]; public [/color][color=#0000bb]float dtb[/color][color=#007700];}public class [/color][color=#0000bb]classhocsinh [/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 input[/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]hocsinh a[/color][color=#007700]=new [/color][color=#0000bb]hocsinh[/color][color=#007700](); [/color][color=#0000bb]hocsinh b[/color][color=#007700]=new [/color][color=#0000bb]hocsinh[/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]"+hoc sinh 1:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" ho ten:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]hoten[/color][color=#007700]=[/color][color=#0000bb]input[/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]" lop:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]lop[/color][color=#007700]=[/color][color=#0000bb]input[/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]" diem trung binh:"[/color][color=#007700]); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]dtb[/color][color=#007700]=[/color][color=#0000bb]input[/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]"+hoc sinh 2:"[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]" ho ten:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]hoten[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]hoten[/color][color=#007700]=[/color][color=#0000bb]input[/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]" lop:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]lop[/color][color=#007700]=[/color][color=#0000bb]input[/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]" diem trung binh:"[/color][color=#007700]); [/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]dtb[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); if([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]dtb[/color][color=#007700]>[/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]dtb[/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]hoten[/color][color=#007700]+[/color][color=#dd0000]" co diem trung binh cao hon"[/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]"+"[/color][color=#007700]+[/color][color=#0000bb]b[/color][color=#007700].[/color][color=#0000bb]hoten[/color][color=#007700]+[/color][color=#dd0000]" co diem trung binh cao hon"[/color][color=#007700]); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  8. #28
    Ngày tham gia
    Feb 2015
    Bài viết
    0
    mong mọi người chỉ bảo thêm !
    fix sau chỗ điểm < 0, >10 thì phải nhập lại ! ( tham khảo của ace :d )
    <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ã:
    /*
    /*
     * to change this license header, choose license headers in project properties.
     * to change this template file, choose tools | templates
     * and open the template in the editor.
     */
    package learningjava;
     
    import java.util.*;
     
    /**
     *
     * @author le
     */
    class hocsinh {
     
        public string name;
        public string class;
        public double diemtb;
        public void input() {
            scanner input = new scanner(system.in);
            system.out.print("\t + nhap ten hoc sinh: ");
            name = input.nextline();
            system.out.print("\t + nhap lop hoc sinh: ");
            class = input.nextline();
            system.out.print("\t + nhap diem trung binh cua hoc sinh: ");
            do{
                diemtb = input.nextdouble();
            } while(diemtb < 0||diemtb>10);
            }
     
        public void show() {
            system.out.println(" + name : " + name);
            system.out.println(" + class : " + class);
            system.out.println(" + average : " + diemtb);
        }
     
        public void compare(hocsinh b) {
            if (diemtb > b.diemtb) {
                system.out.println(" - hoc sinh " + name + " co diem trung binh cao hon !");
            } else if (diemtb == b.diemtb) {
                system.out.println(" - hai hoc sinh " + name + " " + b.name + " co so diem trung binh bang nhau !");
            } else {
                system.out.println(" - hoc sinh " + b.name + " co diem trung binh cao hon");
            }
        }
    }
     
    public class learningclass {
     
        public static void main(string[] args) {
            hocsinh a = new hocsinh();
            hocsinh b = new hocsinh();
            system.out.println(" - nhap thong tin hoc sinh a");
            a.input();
            system.out.println(" - nhap thong tin hoc sinh b");
            b.input();
            a.compare(b);
            system.out.println(" *** thong tin ve hai hoc sinh vua nhap ***");
            a.show();
            b.show();
        }
    }
    </blockquote></div>
    </div>
    </div>

  9. #29
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    <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 HTML:
    
    
    </blockquote></div>
    </div>
    </div>

  10. #30
    Ngày tham gia
    Mar 2016
    Bài viết
    9
    mình nộp bài, nhờ bạn tiasangmoi92 xem giúp vs


    Mã:
    class hocsinh {
     
        public string hoten, lop;
     
        public double dtb;
     
     
     
        public string gethoten() {
     
            return hoten;
     
        }
     
     
     
        public void sethoten(string hoten) {
     
            hoten = hoten;
     
        }
     
     
     
        public string getlop() {
     
            return lop;
     
        }
     
     
     
        public void setlop(string lop) {
     
            lop = lop;
     
        }
     
     
     
        public double getdtb() {
     
            return dtb;
     
        }
     
     
     
        public void setdtb(double dtb) {
     
            dtb = dtb;
     
        }
     
     
     
        public void nhaptt() {
     
            scanner input = new scanner(system.in);
     
            system.out.println("nhap thong tin cho hoc sinh:");
     
            system.out.println("ho ten:");
     
            hoten = input.nextline();
     
            system.out.println("lop:");
     
            lop = input.nextline();
     
            system.out.println("diem trung binh:");
     
            dtb = input.nextdouble();
     
        }
     
     
     
        public void xuattt() {
     
            system.out.println("ho ten:" + hoten.tostring());
     
            system.out.println("lop:" + lop.tostring());
     
            system.out.println("diem trung binh:" + dtb);
     
        }
     
    }
     
     
     
    public class bai1 {
     
        public static void main(string[] args) {
     
            hocsinh a = new hocsinh();
     
            a.nhaptt();
     
            hocsinh b = new hocsinh();
     
            b.nhaptt();
     
            if (a.dtb > b.dtb) {
     
                system.out.println("a co diem trung binh cao hon");
     
                a.xuattt();
     
            } else {
     
                if (a.dtb < b.dtb) {
     
                    system.out.println("b co diem trung binh cao hon");
     
                    b.xuattt();
     
                } else {
     
                    system.out.println("hai nguoi co diem trung binh bang nhau");
     
                    a.xuattt();
     
                    b.xuattt();
     
                }
     
            }
     
        }
     
    }

Trang 3 của 5 Đầu tiênĐầu tiên 12345 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
  •