Trang 4 của 4 Đầu tiênĐầu tiên ... 234
Kết quả 31 đến 39 của 39
  1. #31
    Ngày tham gia
    May 2015
    Bài viết
    0
    Mã nguồn PHP:
    [color=#000000]
    package baitapvenha[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]text[/color][color=#007700].[/color][color=#0000bb]simpledateformat[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]date[/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];[/color][color=#ff8000]/** * bài 1: class hàng hóa gồm các thuộc tính: mã hàng, tên hàng, giá, số lượng. * tạo phương thức tính tiền tổng hóa đơn hàng hóa đó với 2 tham số truyền vào * là giá, và số lượng. tạo phương thức nạp chồng phương thức trên, có thêm tham * số truyền vào nữa là % giảm giá. tính tiền dựa vào các thông số này! tạo đối * tượng dựa và class trên và hiện thị thông tin hóa đơn ra ngoài theo từng * trường hợp! */[/color][color=#007700]public class [/color][color=#0000bb]buoi17_overload [/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]hanghoa17 hang [/color][color=#007700]= new [/color][color=#0000bb]hanghoa17[/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 hang hoa: "[/color][color=#007700]); [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]nhaptt[/color][color=#007700](); [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]xuathd[/color][color=#007700](); }} class [/color][color=#0000bb]hanghoa17[/color][color=#007700]{ private [/color][color=#0000bb]string mahang[/color][color=#007700], [/color][color=#0000bb]tenhang[/color][color=#007700]; private [/color][color=#0000bb]int soluong[/color][color=#007700]; private [/color][color=#0000bb]float dongia[/color][color=#007700]; public [/color][color=#0000bb]void nhaptt[/color][color=#007700](){ [/color][color=#0000bb]scanner sc [/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]"ma hang : "[/color][color=#007700]); [/color][color=#0000bb]mahang [/color][color=#007700]= [/color][color=#0000bb]sc[/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]"ten hang : "[/color][color=#007700]); [/color][color=#0000bb]tenhang [/color][color=#007700]= [/color][color=#0000bb]sc[/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]"don gia : "[/color][color=#007700]); do { [/color][color=#0000bb]dongia [/color][color=#007700]= [/color][color=#0000bb]sc[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); } while ([/color][color=#0000bb]dongia[/color][color=#007700]<=[/color][color=#0000bb]0[/color][color=#007700]); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"so luong: "[/color][color=#007700]); do { [/color][color=#0000bb]soluong [/color][color=#007700]= [/color][color=#0000bb]sc[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); } while ([/color][color=#0000bb]soluong[/color][color=#007700]<=[/color][color=#0000bb]0[/color][color=#007700]); } public [/color][color=#0000bb]string xuathd[/color][color=#007700]([/color][color=#0000bb]string mahang[/color][color=#007700]) { [/color][color=#0000bb]string s [/color][color=#007700]= [/color][color=#dd0000]"
    thong tin cua san pham co ma "[/color][color=#007700]+ [/color][color=#0000bb]mahang[/color][color=#007700]+[/color][color=#dd0000]" vua duoc mua la: "[/color][color=#007700]; [/color][color=#0000bb]s[/color][color=#007700]+=[/color][color=#dd0000]" "[/color][color=#007700]+[/color][color=#0000bb]tenhang[/color][color=#007700]+[/color][color=#dd0000]" co gia "[/color][color=#007700]+[/color][color=#0000bb]dongia[/color][color=#007700]+[/color][color=#dd0000]" $ duoc mua voi "[/color][color=#007700]+[/color][color=#0000bb]soluong[/color][color=#007700]+[/color][color=#dd0000]" san pham."[/color][color=#007700]; [/color][color=#0000bb]date time [/color][color=#007700]= new [/color][color=#0000bb]date[/color][color=#007700](); [/color][color=#0000bb]simpledateformat dinhdangtime [/color][color=#007700]= new [/color][color=#0000bb]simpledateformat[/color][color=#007700]([/color][color=#dd0000]"hh:mm:ss"[/color][color=#007700]); [/color][color=#0000bb]string hienthitime [/color][color=#007700]= [/color][color=#0000bb]dinhdangtime[/color][color=#007700].[/color][color=#0000bb]format[/color][color=#007700]([/color][color=#0000bb]time[/color][color=#007700]); [/color][color=#0000bb]string timesale[/color][color=#007700][] = [/color][color=#0000bb]hienthitime[/color][color=#007700].[/color][color=#0000bb]split[/color][color=#007700]([/color][color=#dd0000]":"[/color][color=#007700]); if([/color][color=#0000bb]12[/color][color=#007700]<=[/color][color=#0000bb]integer[/color][color=#007700].[/color][color=#0000bb]parseint[/color][color=#007700]([/color][color=#0000bb]timesale[/color][color=#007700][[/color][color=#0000bb]0[/color][color=#007700]])&& [/color][color=#0000bb]15[/color][color=#007700]>=[/color][color=#0000bb]integer[/color][color=#007700].[/color][color=#0000bb]parseint[/color][color=#007700]([/color][color=#0000bb]timesale[/color][color=#007700][[/color][color=#0000bb]0[/color][color=#007700]])) return [/color][color=#0000bb]s[/color][color=#007700]+=[/color][color=#dd0000]"
    =>thanh tien: "[/color][color=#007700]+[/color][color=#0000bb]dongia[/color][color=#007700]+[/color][color=#dd0000]"x"[/color][color=#007700]+[/color][color=#0000bb]soluong[/color][color=#007700]+[/color][color=#dd0000]" = " [/color][color=#007700]+ [/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]dongia[/color][color=#007700], [/color][color=#0000bb]soluong[/color][color=#007700], [/color][color=#0000bb]15[/color][color=#007700]); return [/color][color=#0000bb]s[/color][color=#007700]+=[/color][color=#dd0000]"
    =>thanh tien: "[/color][color=#007700]+[/color][color=#0000bb]dongia[/color][color=#007700]+[/color][color=#dd0000]"x"[/color][color=#007700]+[/color][color=#0000bb]soluong[/color][color=#007700]+[/color][color=#dd0000]" = " [/color][color=#007700]+ [/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]dongia[/color][color=#007700], [/color][color=#0000bb]soluong[/color][color=#007700]); } public [/color][color=#0000bb]void xuathd[/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=#0000bb]xuathd[/color][color=#007700]([/color][color=#0000bb]mahang[/color][color=#007700])); } public [/color][color=#0000bb]float tongtien[/color][color=#007700]([/color][color=#0000bb]float dongia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700]){ return [/color][color=#0000bb]dongia[/color][color=#007700]*[/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]float tongtien[/color][color=#007700]([/color][color=#0000bb]float dongia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]float giamgia[/color][color=#007700]){ return [/color][color=#0000bb]dongia[/color][color=#007700]*[/color][color=#0000bb]soluong[/color][color=#007700]*[/color][color=#0000bb]giamgia[/color][color=#007700]/[/color][color=#0000bb]100[/color][color=#007700]; }}[/color] 
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bt overload (move your mouse to reveal the content)</noscript>

    bt overload (open)
    bt overload (close)

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

  2. #32
    Ngày tham gia
    Aug 2015
    Bài viết
    7
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>mình nộp bài :d (move your mouse to reveal the content)</noscript>

    mình nộp bài :d (open)
    mình nộp bài :d (close)

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


    Mã nguồn PHP:
    [color=#000000]
    [/color][color=#007700]public class [/color][color=#0000bb]bai1_unit17 [/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]goods g [/color][color=#007700]= new [/color][color=#0000bb]goods[/color][color=#007700](); [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]input[/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]"mat hang " [/color][color=#007700]+ [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getten[/color][color=#007700]() + [/color][color=#dd0000]" duoc ban voi gia " [/color][color=#007700]+ [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getgia[/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]"tong thiet hai cua thang cu co nguoi yeu la" [/color][color=#007700]+ [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]sum[/color][color=#007700]([/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getgia[/color][color=#007700](), [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getsoluong[/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]"cung la mat hang tren nhung duoc giam gia "[/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]"thi thang cu kia do ton tien, va phai tra " [/color][color=#007700]+ [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]sum[/color][color=#007700]([/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getgia[/color][color=#007700](), [/color][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]getsoluong[/color][color=#007700](), [/color][color=#0000bb]20[/color][color=#007700])); }} class [/color][color=#0000bb]goods [/color][color=#007700]{ private [/color][color=#0000bb]string ma[/color][color=#007700]; private [/color][color=#0000bb]string ten[/color][color=#007700]; private [/color][color=#0000bb]long gia[/color][color=#007700]; private [/color][color=#0000bb]int soluong[/color][color=#007700]; public [/color][color=#0000bb]string getma[/color][color=#007700]() { return [/color][color=#0000bb]ma[/color][color=#007700]; } public [/color][color=#0000bb]void setma[/color][color=#007700]([/color][color=#0000bb]string ma[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]ma [/color][color=#007700]= [/color][color=#0000bb]ma[/color][color=#007700]; } public [/color][color=#0000bb]string getten[/color][color=#007700]() { return [/color][color=#0000bb]ten[/color][color=#007700]; } public [/color][color=#0000bb]void setten[/color][color=#007700]([/color][color=#0000bb]string ten[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]ten [/color][color=#007700]= [/color][color=#0000bb]ten[/color][color=#007700]; } public [/color][color=#0000bb]long getgia[/color][color=#007700]() { return [/color][color=#0000bb]gia[/color][color=#007700]; } public [/color][color=#0000bb]void setgia[/color][color=#007700]([/color][color=#0000bb]long gia[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]gia [/color][color=#007700]= [/color][color=#0000bb]gia[/color][color=#007700]; } public [/color][color=#0000bb]int getsoluong[/color][color=#007700]() { return [/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]void setsoluong[/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]soluong [/color][color=#007700]= [/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]void input[/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap cac thong tin ve mat hang:"[/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 ma:"[/color][color=#007700]); [/color][color=#0000bb]setma[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap ten:"[/color][color=#007700]); [/color][color=#0000bb]setten[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap gia:"[/color][color=#007700]); [/color][color=#0000bb]setgia[/color][color=#007700]([/color][color=#0000bb]input[/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]"nhap so luong:"[/color][color=#007700]); [/color][color=#0000bb]setsoluong[/color][color=#007700]([/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]()); } public [/color][color=#0000bb]void show[/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 ve mat hang"[/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]"ma:" [/color][color=#007700]+ [/color][color=#0000bb]getma[/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]"ten:" [/color][color=#007700]+ [/color][color=#0000bb]getten[/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]"gia:" [/color][color=#007700]+ [/color][color=#0000bb]getgia[/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]"so luong:" [/color][color=#007700]+ [/color][color=#0000bb]getsoluong[/color][color=#007700]()); } public [/color][color=#0000bb]double sum[/color][color=#007700]( [/color][color=#0000bb]long gia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700]) { return [/color][color=#0000bb]gia[/color][color=#007700]*[/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]double sum [/color][color=#007700]([/color][color=#0000bb]long gia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]int percent[/color][color=#007700]) { return ([/color][color=#0000bb]gia[/color][color=#007700]*[/color][color=#0000bb]soluong[/color][color=#007700]*([/color][color=#0000bb]100 [/color][color=#007700]- [/color][color=#0000bb]percent[/color][color=#007700]))/[/color][color=#0000bb]100[/color][color=#007700]; }}[/color] 
    </blockquote></div>
    </div>
    </div>

  3. #33
    Ngày tham gia
    Mar 2015
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>em xin nop bai (move your mouse to reveal the content)</noscript>

    em xin nop bai (open)
    em xin nop bai (close)

    </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 unit17[/color][color=#007700]; [/color][color=#ff8000]/** * * @author quanghuy */[/color][color=#007700]public class [/color][color=#0000bb]unit17 [/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=#ff8000]// todo code application logic here [/color][color=#0000bb]hanghoa a [/color][color=#007700]= new [/color][color=#0000bb]hanghoa[/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]"tong so tien thanh toan chua giam gia:" [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]35.6f[/color][color=#007700], [/color][color=#0000bb]45[/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]"tong so tien thanh toan da giam gia la: " [/color][color=#007700]+ [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]35.6f[/color][color=#007700], [/color][color=#0000bb]45[/color][color=#007700], [/color][color=#0000bb]0.35f[/color][color=#007700])); }} class [/color][color=#0000bb]hanghoa [/color][color=#007700]{ public [/color][color=#0000bb]string mahang[/color][color=#007700]; public [/color][color=#0000bb]string tenhang[/color][color=#007700]; public [/color][color=#0000bb]float gia[/color][color=#007700]; public [/color][color=#0000bb]int soluong[/color][color=#007700]; public [/color][color=#0000bb]float giamgia[/color][color=#007700]; public [/color][color=#0000bb]float tongtien[/color][color=#007700]([/color][color=#0000bb]float gia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700]) { return (float) ([/color][color=#0000bb]gia [/color][color=#007700]* [/color][color=#0000bb]soluong[/color][color=#007700]); } public [/color][color=#0000bb]float tongtien[/color][color=#007700]([/color][color=#0000bb]float gia[/color][color=#007700], [/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]float giamgia[/color][color=#007700]) { return (float) ([/color][color=#0000bb]gia [/color][color=#007700]* [/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]giamgia[/color][color=#007700]); }}[/color] 
    </blockquote></div>
    </div>
    </div>

  4. #34
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>nộp bài (move your mouse to reveal the content)</noscript>

    nộp bài (open)
    nộp bài (close)

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

    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>class hàng hóa (move your mouse to reveal the content)</noscript>

    class hàng hóa (open)
    class hàng hóa (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package lesson17[/color][color=#007700]; public class [/color][color=#0000bb]hanghoa [/color][color=#007700]{ private [/color][color=#0000bb]double soluong[/color][color=#007700];private [/color][color=#0000bb]double gia[/color][color=#007700];private [/color][color=#0000bb]double giamgia[/color][color=#007700]; public [/color][color=#0000bb]double getsoluong[/color][color=#007700]() {return [/color][color=#0000bb]soluong[/color][color=#007700];}public [/color][color=#0000bb]void setsoluong[/color][color=#007700]([/color][color=#0000bb]double soluong[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]soluong [/color][color=#007700]= [/color][color=#0000bb]soluong[/color][color=#007700];}public [/color][color=#0000bb]double getgia[/color][color=#007700]() {return [/color][color=#0000bb]gia[/color][color=#007700];}public [/color][color=#0000bb]void setgia[/color][color=#007700]([/color][color=#0000bb]double gia[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]gia [/color][color=#007700]= [/color][color=#0000bb]gia[/color][color=#007700];}public [/color][color=#0000bb]double getgiamgia[/color][color=#007700]() {return [/color][color=#0000bb]giamgia[/color][color=#007700];}public [/color][color=#0000bb]void setgiamgia[/color][color=#007700]([/color][color=#0000bb]double giamgia[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]giamgia [/color][color=#007700]= [/color][color=#0000bb]giamgia[/color][color=#007700];} public [/color][color=#0000bb]double tongtien[/color][color=#007700]([/color][color=#0000bb]double soluong[/color][color=#007700], [/color][color=#0000bb]double gia[/color][color=#007700]){return (double) [/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]gia[/color][color=#007700];} public [/color][color=#0000bb]double tongtien[/color][color=#007700]([/color][color=#0000bb]double soluong[/color][color=#007700], [/color][color=#0000bb]double gia[/color][color=#007700], [/color][color=#0000bb]double giamgia[/color][color=#007700]){return (double) [/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]gia[/color][color=#007700]* ([/color][color=#0000bb]1[/color][color=#007700]-[/color][color=#0000bb]giamgia[/color][color=#007700]/[/color][color=#0000bb]100[/color][color=#007700]);} }[/color] 
    </blockquote></div>
    </div>
    </div>

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

    class main (open)
    class main (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package lesson17[/color][color=#007700]; [/color][color=#0000bb]import [/color][color=#007700]static [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]lang[/color][color=#007700].[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/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]main [/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]hanghoa hang [/color][color=#007700]= new [/color][color=#0000bb]hanghoa[/color][color=#007700](); [/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap vao so luong hang: "[/color][color=#007700]);[/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]setsoluong[/color][color=#007700]([/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]()); [/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap vao gia hang: "[/color][color=#007700]);[/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]setgia[/color][color=#007700]([/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]()); [/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap vao phan tram giam gia: "[/color][color=#007700]);[/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]setgiamgia[/color][color=#007700]([/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextdouble[/color][color=#007700]()); [/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"tong tien chua giam la: " [/color][color=#007700]+ [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]getsoluong[/color][color=#007700](), [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]getgia[/color][color=#007700]()));[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"tong tien chua giam la: " [/color][color=#007700]+ [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]getsoluong[/color][color=#007700](), [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]getgia[/color][color=#007700](), [/color][color=#0000bb]hang[/color][color=#007700].[/color][color=#0000bb]getgiamgia[/color][color=#007700]()));}}[/color] 
    </blockquote></div>
    </div>
    </div>

    </blockquote></div>
    </div>
    </div>

  5. #35
    Ngày tham gia
    Aug 2015
    Bài viết
    43
    xem hộ e vs ^^
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>thanhtoan (move your mouse to reveal the content)</noscript>

    thanhtoan (open)
    thanhtoan (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package nap[/color][color=#007700].[/color][color=#0000bb]chong[/color][color=#007700].[/color][color=#0000bb]phuong[/color][color=#007700].[/color][color=#0000bb]thuc[/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]hanghoa [/color][color=#007700]{private [/color][color=#0000bb]string mahang[/color][color=#007700], [/color][color=#0000bb]tenhang[/color][color=#007700];private [/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]gia[/color][color=#007700];private [/color][color=#0000bb]float sale[/color][color=#007700]; public [/color][color=#0000bb]string getmahang[/color][color=#007700]() {return [/color][color=#0000bb]mahang[/color][color=#007700];}public [/color][color=#0000bb]void setmahang[/color][color=#007700]([/color][color=#0000bb]string mahang[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]mahang [/color][color=#007700]= [/color][color=#0000bb]mahang[/color][color=#007700];}public [/color][color=#0000bb]string gettenhang[/color][color=#007700]() {return [/color][color=#0000bb]tenhang[/color][color=#007700];}public [/color][color=#0000bb]void settenhang[/color][color=#007700]([/color][color=#0000bb]string tenhang[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]tenhang [/color][color=#007700]= [/color][color=#0000bb]tenhang[/color][color=#007700];}public [/color][color=#0000bb]int getsoluong[/color][color=#007700]() {return [/color][color=#0000bb]soluong[/color][color=#007700];}public [/color][color=#0000bb]void setsoluong[/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]soluong [/color][color=#007700]= [/color][color=#0000bb]soluong[/color][color=#007700];}public [/color][color=#0000bb]int getgia[/color][color=#007700]() {return [/color][color=#0000bb]gia[/color][color=#007700];}public [/color][color=#0000bb]void setgia[/color][color=#007700]([/color][color=#0000bb]int gia[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]gia [/color][color=#007700]= [/color][color=#0000bb]gia[/color][color=#007700];}public [/color][color=#0000bb]float getsale [/color][color=#007700]() {return [/color][color=#0000bb]sale[/color][color=#007700];}public [/color][color=#0000bb]void setsale[/color][color=#007700]([/color][color=#0000bb]float sale[/color][color=#007700]) {[/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]sale [/color][color=#007700]= [/color][color=#0000bb]sale[/color][color=#007700];} public [/color][color=#0000bb]int tongtien [/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]int gia[/color][color=#007700]) {return ([/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]gia[/color][color=#007700]);}public [/color][color=#0000bb]float tongtien [/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]int gia[/color][color=#007700], [/color][color=#0000bb]float sale[/color][color=#007700]) {return ([/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]gia [/color][color=#007700]- [/color][color=#0000bb]soluong [/color][color=#007700]* [/color][color=#0000bb]gia [/color][color=#007700]* [/color][color=#0000bb]sale[/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 sảm phẩm: "[/color][color=#007700]);[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"tên sản phẩm: "[/color][color=#007700]);[/color][color=#0000bb]settenhang[/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]"mã sản phẩm: "[/color][color=#007700]);[/color][color=#0000bb]setmahang[/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]"số lượng: "[/color][color=#007700]);[/color][color=#0000bb]setsoluong[/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]"giá: "[/color][color=#007700]);[/color][color=#0000bb]setgia[/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]"giảm giá: " [/color][color=#007700]);[/color][color=#0000bb]setsale[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700]());} public [/color][color=#0000bb]void showhoadon [/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 hóa đơn: "[/color][color=#007700]);[/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"tên sản phẩm:" [/color][color=#007700]+ [/color][color=#0000bb]gettenhang[/color][color=#007700]() + [/color][color=#dd0000]" mã sản phẩm:" [/color][color=#007700]+ [/color][color=#0000bb]getmahang[/color][color=#007700]() + [/color][color=#dd0000]" số lượng:" [/color][color=#007700]+ [/color][color=#0000bb]getsoluong[/color][color=#007700]() + [/color][color=#dd0000]" giá:" [/color][color=#007700]+ [/color][color=#0000bb]getgia[/color][color=#007700]() +[/color][color=#dd0000]" sale:" [/color][color=#007700]+ [/color][color=#0000bb]getsale[/color][color=#007700]() + [/color][color=#dd0000]"%" [/color][color=#007700]+ [/color][color=#dd0000]" tổng tiền:" [/color][color=#007700]+ [/color][color=#0000bb]tongtien[/color][color=#007700]([/color][color=#0000bb]getsoluong[/color][color=#007700](), [/color][color=#0000bb]getgia[/color][color=#007700](), [/color][color=#0000bb]getsale[/color][color=#007700]()));}} public class [/color][color=#0000bb]thanhtoan [/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]hanghoa hh [/color][color=#007700]= new [/color][color=#0000bb]hanghoa[/color][color=#007700]();[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]input[/color][color=#007700]();[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]showhoadon[/color][color=#007700]();}}[/color] 
    </blockquote></div>
    </div>
    </div>

  6. #36
    Ngày tham gia
    Dec 2014
    Bài viết
    0
    Trích dẫn Gửi bởi quagn1998
    không biết đúng không nhỉ? code của em:
    <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 unit17_napchong[/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]hanghoa [/color][color=#007700]{ private [/color][color=#0000bb]string mahang[/color][color=#007700], [/color][color=#0000bb]tenhang[/color][color=#007700]; private [/color][color=#0000bb]long gia[/color][color=#007700], [/color][color=#0000bb]soluong[/color][color=#007700], [/color][color=#0000bb]thanhtien[/color][color=#007700]; private [/color][color=#0000bb]float giamgia[/color][color=#007700]; public [/color][color=#0000bb]string getmahang[/color][color=#007700]() { return [/color][color=#0000bb]mahang[/color][color=#007700]; } public [/color][color=#0000bb]void setmahang[/color][color=#007700]([/color][color=#0000bb]string mahang[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]mahang [/color][color=#007700]= [/color][color=#0000bb]mahang[/color][color=#007700]; } public [/color][color=#0000bb]string gettenhang[/color][color=#007700]() { return [/color][color=#0000bb]tenhang[/color][color=#007700]; } public [/color][color=#0000bb]void settenhang[/color][color=#007700]([/color][color=#0000bb]string tenhang[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]tenhang [/color][color=#007700]= [/color][color=#0000bb]tenhang[/color][color=#007700]; } public [/color][color=#0000bb]long getgia[/color][color=#007700]() { return [/color][color=#0000bb]gia[/color][color=#007700]; } public [/color][color=#0000bb]void setgia[/color][color=#007700]([/color][color=#0000bb]long gia[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]gia [/color][color=#007700]= [/color][color=#0000bb]gia[/color][color=#007700]; } public [/color][color=#0000bb]long getsoluong[/color][color=#007700]() { return [/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]void setsoluong[/color][color=#007700]([/color][color=#0000bb]long soluong[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]soluong [/color][color=#007700]= [/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]float getgiamgia[/color][color=#007700]() { return [/color][color=#0000bb]giamgia[/color][color=#007700]; } public [/color][color=#0000bb]void setgiamgia[/color][color=#007700]([/color][color=#0000bb]float giamgia[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]giamgia [/color][color=#007700]= [/color][color=#0000bb]giamgia[/color][color=#007700]; } public [/color][color=#0000bb]void setthanhtien[/color][color=#007700]([/color][color=#0000bb]long thanhtien[/color][color=#007700]) { [/color][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]thanhtien [/color][color=#007700]= [/color][color=#0000bb]thanhtien[/color][color=#007700]; } public [/color][color=#0000bb]long getthanhtien[/color][color=#007700]() { return [/color][color=#0000bb]thanhtien[/color][color=#007700]; } public [/color][color=#0000bb]long tinhtien[/color][color=#007700]([/color][color=#0000bb]long gia[/color][color=#007700], [/color][color=#0000bb]long soluong[/color][color=#007700]) { return [/color][color=#0000bb]gia [/color][color=#007700]* [/color][color=#0000bb]soluong[/color][color=#007700]; } public [/color][color=#0000bb]long tinhtien[/color][color=#007700]([/color][color=#0000bb]long gia[/color][color=#007700], [/color][color=#0000bb]long soluong[/color][color=#007700], [/color][color=#0000bb]float giamgia[/color][color=#007700]) { return ([/color][color=#0000bb]long[/color][color=#007700]) (([/color][color=#0000bb]long[/color][color=#007700]) [/color][color=#0000bb]gia [/color][color=#007700]* [/color][color=#0000bb]soluong [/color][color=#007700]* ([/color][color=#0000bb]100.00 [/color][color=#007700]- [/color][color=#0000bb]giamgia[/color][color=#007700]) / [/color][color=#0000bb]100[/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].print([/color][color=#dd0000]"nhập mã hàng: "[/color][color=#007700]); [/color][color=#0000bb]setmahang[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]next[/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 hàng: "[/color][color=#007700]); [/color][color=#0000bb]settenhang[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]next[/color][color=#007700]()); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập giá: "[/color][color=#007700]); [/color][color=#0000bb]setgia[/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].print([/color][color=#dd0000]"nhập số lượng: "[/color][color=#007700]); [/color][color=#0000bb]setsoluong[/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].print([/color][color=#dd0000]"nhập % giảm giá: "[/color][color=#007700]); [/color][color=#0000bb]setgiamgia[/color][color=#007700]([/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextfloat[/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]"mã hàng: " [/color][color=#007700]+ [/color][color=#0000bb]getmahang[/color][color=#007700]() + [/color][color=#dd0000]" tên hàng: " [/color][color=#007700]+ [/color][color=#0000bb]gettenhang[/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á: " [/color][color=#007700]+ [/color][color=#0000bb]getgia[/color][color=#007700]() + [/color][color=#dd0000]" số lượng: " [/color][color=#007700]+ [/color][color=#0000bb]getsoluong[/color][color=#007700]()); if ([/color][color=#0000bb]giamgia [/color][color=#007700]== [/color][color=#0000bb]0.0[/color][color=#007700]) { [/color][color=#0000bb]setthanhtien[/color][color=#007700]([/color][color=#0000bb]tinhtien[/color][color=#007700]([/color][color=#0000bb]gia[/color][color=#007700], [/color][color=#0000bb]soluong[/color][color=#007700])); } else { [/color][color=#0000bb]setthanhtien[/color][color=#007700]([/color][color=#0000bb]tinhtien[/color][color=#007700]([/color][color=#0000bb]gia[/color][color=#007700], [/color][color=#0000bb]soluong[/color][color=#007700], [/color][color=#0000bb]giamgia[/color][color=#007700])); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"thành tiền: " [/color][color=#007700]+ [/color][color=#0000bb]getthanhtien[/color][color=#007700]()); }} public class [/color][color=#0000bb]quanlybanhang [/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]hanghoa a [/color][color=#007700]= new [/color][color=#0000bb]hanghoa[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]input[/color][color=#007700](); [/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]output[/color][color=#007700](); }}[/color] 
    </blockquote></div>
    </div>
    </div>
    áp dụng bài nạp chồng phương thức bạn ạ. có nghĩa là phải gi giảm giá nữa, rồi sau đó mới in ra hai trường hợp là tiền tổng chưa giảm giá và tiền tổng đã giảm giá. code 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 sale[/color][color=#007700];[/color][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].*;class [/color][color=#0000bb]hanghoa[/color][color=#007700]{public [/color][color=#0000bb]string mahang[/color][color=#007700];public [/color][color=#0000bb]string tenhang[/color][color=#007700];public [/color][color=#0000bb]int soluong[/color][color=#007700];public [/color][color=#0000bb]float gia[/color][color=#007700];public [/color][color=#0000bb]float giamgia[/color][color=#007700];public [/color][color=#0000bb]float tientong[/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]float gia[/color][color=#007700]){return [/color][color=#0000bb]soluong[/color][color=#007700]*[/color][color=#0000bb]gia[/color][color=#007700];}public [/color][color=#0000bb]float tientong[/color][color=#007700]([/color][color=#0000bb]int soluong[/color][color=#007700], [/color][color=#0000bb]float gia[/color][color=#007700], [/color][color=#0000bb]float giamgia[/color][color=#007700]){return ([/color][color=#0000bb]soluong[/color][color=#007700]*[/color][color=#0000bb]gia[/color][color=#007700]*([/color][color=#0000bb]100[/color][color=#007700]-[/color][color=#0000bb]giamgia[/color][color=#007700]))/[/color][color=#0000bb]100[/color][color=#007700];}}public class [/color][color=#0000bb]banhang [/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 sint[/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 sstring[/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 sfloat[/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]hanghoa hh[/color][color=#007700]=new [/color][color=#0000bb]hanghoa[/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 hàng: "[/color][color=#007700]);[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]tenhang[/color][color=#007700]=[/color][color=#0000bb]sstring[/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 mã hàng: "[/color][color=#007700]);[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]mahang[/color][color=#007700]=[/color][color=#0000bb]sstring[/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 số lượng: "[/color][color=#007700]);[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]soluong[/color][color=#007700]=[/color][color=#0000bb]sint[/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]"nhập giá: "[/color][color=#007700]);[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]gia[/color][color=#007700]=[/color][color=#0000bb]sfloat[/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 % giảm giá: "[/color][color=#007700]);[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]giamgia[/color][color=#007700]=[/color][color=#0000bb]sfloat[/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]"giá thành gốc là: "[/color][color=#007700]+[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]tientong[/color][color=#007700]([/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]soluong[/color][color=#007700], [/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]gia[/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á sau khi giảm là: "[/color][color=#007700]+[/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]tientong[/color][color=#007700]([/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]soluong[/color][color=#007700], [/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]gia[/color][color=#007700], [/color][color=#0000bb]hh[/color][color=#007700].[/color][color=#0000bb]giamgia[/color][color=#007700]));}}[/color] 
    </blockquote></div>
    </div>
    </div>

  7. #37
    Ngày tham gia
    Apr 2015
    Bài viết
    0
    <div class="bbcodeblock bbcodequote bbcmspoilerblock">
    <div class="attribution type"><noscript>bt (move your mouse to reveal the content)</noscript>

    bt (open)
    bt (close)

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


    Mã nguồn PHP:
    [color=#000000]
    package overloading[/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]hang[/color][color=#007700]{public [/color][color=#0000bb]string ten[/color][color=#007700],[/color][color=#0000bb]ma[/color][color=#007700];public [/color][color=#0000bb]int gia[/color][color=#007700],[/color][color=#0000bb]sl[/color][color=#007700];[/color][color=#0000bb]int tinhtien[/color][color=#007700]([/color][color=#0000bb]int gia[/color][color=#007700],[/color][color=#0000bb]int sl[/color][color=#007700]){return (int)[/color][color=#0000bb]gia[/color][color=#007700]*[/color][color=#0000bb]sl[/color][color=#007700];}[/color][color=#0000bb]float tinhtien[/color][color=#007700]([/color][color=#0000bb]int gia[/color][color=#007700], [/color][color=#0000bb]int sl[/color][color=#007700],[/color][color=#0000bb]float giam[/color][color=#007700]){return (float)[/color][color=#0000bb]gia[/color][color=#007700]*[/color][color=#0000bb]sl[/color][color=#007700]*([/color][color=#0000bb]100[/color][color=#007700]-[/color][color=#0000bb]giam[/color][color=#007700])/[/color][color=#0000bb]100[/color][color=#007700];}} class [/color][color=#0000bb]overloading[/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 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]hang a[/color][color=#007700]=new [/color][color=#0000bb]hang[/color][color=#007700]();[/color][color=#0000bb]string hd[/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 ten hang :"[/color][color=#007700]);[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]ten[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap ma hang :"[/color][color=#007700]);[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]ma[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap gia "[/color][color=#007700]);[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gia[/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhap so luong hang"[/color][color=#007700]);[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sl[/color][color=#007700]=[/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700]();do{ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"co duoc khuyen mai hay khong(co/khong)?"[/color][color=#007700]);[/color][color=#0000bb]hd[/color][color=#007700]=[/color][color=#0000bb]inp[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700]();if ([/color][color=#0000bb]hd[/color][color=#007700]!=[/color][color=#dd0000]"co"[/color][color=#007700]&&[/color][color=#0000bb]hd[/color][color=#007700]!=[/color][color=#dd0000]"khong"[/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 sai!!!"[/color][color=#007700]);}} while ([/color][color=#0000bb]hd[/color][color=#007700]==[/color][color=#dd0000]"co"[/color][color=#007700]||[/color][color=#0000bb]hd[/color][color=#007700]==[/color][color=#dd0000]"khong"[/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=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/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=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/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=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/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=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/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]"ten hang :"[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]ten[/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]"ma hang:"[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]ma[/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]"don gia"[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gia[/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]"so luong "[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sl[/color][color=#007700]);if ([/color][color=#0000bb]hd[/color][color=#007700]==[/color][color=#dd0000]"co"[/color][color=#007700]){[/color][color=#0000bb]float s[/color][color=#007700]=[/color][color=#0000bb]20[/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]"khuyen mai 20%"[/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]"tong cong"[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]tinhtien[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gia[/color][color=#007700],[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sl[/color][color=#007700],[/color][color=#0000bb]s[/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]"tong cong"[/color][color=#007700]+[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]tinhtien[/color][color=#007700]([/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]gia[/color][color=#007700],[/color][color=#0000bb]a[/color][color=#007700].[/color][color=#0000bb]sl[/color][color=#007700])); } }} [/color] 
    </blockquote></div>
    </div>
    </div>

  8. #38
    Ngày tham gia
    Apr 2016
    Bài viết
    0

    Nạp chống biết sử dụng thì rất hay

    Phương thức nạp chống này rất hay, tuy nhiên để sử dụng thì hơi khó, chắc phải nghiên cứu kỹ thì mới dám dùng,

  9. #39
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    bài viết rất chi tiết đung thứ mình đang cần cảm ơn bạn đã chia sẻ

Trang 4 của 4 Đầu tiênĐầu tiên ... 234

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
  •