-
01-14-2014, 07:00 AM #71Junior Member
- Ngày tham gia
- Jul 2014
- Đang ở
- QUẦN ÁO SỈ LẺ GIÁ RẺ NHẤT LÀ NGUỒN CUNG CẤP QUẦN ÁO HOTGIRL. ~* Xưởng may tr
- 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]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 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]string hovaten[/color][color=#007700]; [/color][color=#0000bb]int namsinh[/color][color=#007700]; [/color][color=#0000bb]float dtoan[/color][color=#007700], [/color][color=#0000bb]dly[/color][color=#007700], [/color][color=#0000bb]dhoa[/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]"nhập họ và tên: "[/color][color=#007700]); [/color][color=#0000bb]hovaten [/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập năm sinh: "[/color][color=#007700]); [/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/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]"nhập điểm toán: "[/color][color=#007700]); [/color][color=#0000bb]dtoan [/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập điểm lý: "[/color][color=#007700]); [/color][color=#0000bb]dly [/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].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"nhập điểm hóa: "[/color][color=#007700]); [/color][color=#0000bb]dhoa [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); [/color][color=#0000bb]dtb [/color][color=#007700]= ([/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]; if ( [/color][color=#0000bb]dtb [/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]"học sinh: " [/color][color=#007700]+ [/color][color=#0000bb]hovaten [/color][color=#007700]+ [/color][color=#dd0000]" là học sinh giỏi"[/color][color=#007700]); else if ( [/color][color=#0000bb]dtb [/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]"học sinh: " [/color][color=#007700]+ [/color][color=#0000bb]hovaten [/color][color=#007700]+ [/color][color=#dd0000]" là học sinh khá"[/color][color=#007700]); else if ( [/color][color=#0000bb]dtb [/color][color=#007700]>= [/color][color=#0000bb]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]"học sinh: " [/color][color=#007700]+ [/color][color=#0000bb]hovaten [/color][color=#007700]+ [/color][color=#dd0000]" là học sinh trung bình"[/color][color=#007700]); }[/color]
</div>
</div>
-
02-09-2014, 07:00 AM #72Junior Member
- Ngày tham gia
- Jan 2015
- Bài viết
- 0
hi all,
mình có thắc mắc như thế này khi nhập chuỗi đối với hàm scanner kết hợp vòng lặp for
yêu cầu (trích từ bài tập ở trên): nhập danh sách sinh viên
note1:
nếu trong code mình không có dòng lệnh "in.nextline();" thì kết quả sẽ không cho nhập từng hàng:
Mã nguồn HTML:
Mã:nhap so sinh vien : 2 nhap sinh vien thu : 0 nhap sinh vien thu : 1
note 2:
nếu ở đoạn code trên ta sửa lại
a=in.nextline(); ===> a=in.next();
và bỏ đi dòng lênh "in.nextline();"
kết quả mành hình sẽ cho phép ta nhập cho từng thông báo.
================================================
pro nào giúp mình giải thích trong note1, nếu không có dòng "in.nextline();" thì kết quả tự động trả về 2 thông báo cùng 1 lúc ?
cho mình hỏi, mình nên làm theo note nào (note1 hay note2) trong trường hợp nhập chuỗi với "scanner+ vòng lặp for" thì sẽ tốt hơn
-
02-13-2014, 07:00 AM #73Junior Member
- Ngày tham gia
- Feb 2015
- Bài viết
- 0
bài tap
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]diem[/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]float trungbinh[/color][color=#007700], [/color][color=#0000bb]toan[/color][color=#007700], [/color][color=#0000bb]ly[/color][color=#007700], [/color][color=#0000bb]hoa[/color][color=#007700]; [/color][color=#0000bb]string hoten[/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]"nhap điểm toán: "[/color][color=#007700]); [/color][color=#0000bb]toan [/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]"nhap diem ly: "[/color][color=#007700]); [/color][color=#0000bb]ly [/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]"nhap diem hoa: "[/color][color=#007700]); [/color][color=#0000bb]hoa [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); [/color][color=#0000bb]trungbinh [/color][color=#007700]= (([/color][color=#0000bb]ly[/color][color=#007700]+[/color][color=#0000bb]hoa[/color][color=#007700]+[/color][color=#0000bb]toan[/color][color=#007700])/[/color][color=#0000bb]3[/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 bình 3 môn: " [/color][color=#007700]+ [/color][color=#0000bb]trungbinh[/color][color=#007700]); if([/color][color=#0000bb]trungbinh [/color][color=#007700]< [/color][color=#0000bb]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]"hoc sinh yeu"[/color][color=#007700]); } else if([/color][color=#0000bb]trungbinh [/color][color=#007700]> [/color][color=#0000bb]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]"hoc sinh trung bình"[/color][color=#007700]); } else if([/color][color=#0000bb]trungbinh [/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]"hoc sinh kha"[/color][color=#007700]); } else if([/color][color=#0000bb]trungbinh [/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]"hoc sinh gioi"[/color][color=#007700]); } } }[/color]
-
02-19-2014, 07:00 AM #74Junior Member
- Ngày tham gia
- Feb 2015
- 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ã:public class sinhvien { public static void main(string[] args) { string ho, ten; system.out.print("nhap ho: "); ho = nhaphoten(); system.out.print("nhap ten: "); ten = nhaphoten(); system.out.print("nhap nam sinh: "); nhapnam(); xeploai(); } public static string nhaphoten() { string s = ""; scanner input = new scanner(system.in); boolean check = true; while (check) { try { s = input.nextline(); check = false; } catch (exception e) { system.out.println("chi duoc nhap chu, nhap lai!"); input.nextline(); } } return s; } public static int nhapnam() { int n = 0; scanner input = new scanner(system.in); boolean check = true; while (check) { try { n = input.nextint(); if (n > 0) { check = false; } else { system.out.println("nam phai >0, nhap lai!"); input.nextline(); } } catch (exception e) { system.out.println("chi duoc nhap so, nhap lai!"); input.nextline(); } } return n; } 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("diem chi co gia tri tu 0-10, hay nhap lai!"); input.nextline(); } } catch (exception e) { system.out.println("phai nhap so, nhap lai!"); input.nextline(); } } return n; } public static void xeploai() { system.out.println("nhap diem!"); float diemtoan, diemly, diemhoa; system.out.print("diem toan: "); diemtoan = nhapdiem(); system.out.print("diem ly: "); diemly = nhapdiem(); system.out.print("diem hoa: "); diemhoa = nhapdiem(); float diemtrungbinh = (diemtoan + diemly + diemhoa) / 3; system.out.println("diem trung binh: "+diemtrungbinh); system.out.print("xep loai: "); if (diemtrungbinh > 8) { system.out.println("gioi"); } else if (diemtrungbinh > 6.5) { system.out.println("kha"); } else if (diemtrungbinh > 5) { system.out.println("trung binh"); } else { system.out.println("hen gap lai em nam sau blabla^^....."); } } }
</div>
</div>
-
03-01-2014, 07:00 AM #75Junior Member
- Ngày tham gia
- Jun 2014
- Bài viết
- 0
bai 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]
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];public class [/color][color=#0000bb]nhapdulieu [/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]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"ho va ten:"[/color][color=#007700]); [/color][color=#0000bb]string ht[/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]"nam sinh:"[/color][color=#007700]); [/color][color=#0000bb]int ns[/color][color=#007700]=[/color][color=#0000bb]input[/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]"diem toan:"[/color][color=#007700]); [/color][color=#0000bb]float dt[/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].print([/color][color=#dd0000]"diem li:"[/color][color=#007700]); [/color][color=#0000bb]float dl[/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].print([/color][color=#dd0000]"diem hoa:"[/color][color=#007700]); [/color][color=#0000bb]float dh[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); [/color][color=#0000bb]float dtb[/color][color=#007700]; [/color][color=#0000bb]dtb[/color][color=#007700]=(float)(([/color][color=#0000bb]dt[/color][color=#007700]+[/color][color=#0000bb]dl[/color][color=#007700]+[/color][color=#0000bb]dh[/color][color=#007700])/[/color][color=#0000bb]3[/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]dtb[/color][color=#007700]); if([/color][color=#0000bb]dtb[/color][color=#007700]>=[/color][color=#0000bb]5[/color][color=#007700]&[/color][color=#0000bb]dtb[/color][color=#007700]<[/color][color=#0000bb]7[/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 trung binh"[/color][color=#007700]); if([/color][color=#0000bb]dtb[/color][color=#007700]>=[/color][color=#0000bb]7[/color][color=#007700]&[/color][color=#0000bb]dtb[/color][color=#007700]<[/color][color=#0000bb]9[/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 kha"[/color][color=#007700]); if([/color][color=#0000bb]dtb[/color][color=#007700]>=[/color][color=#0000bb]9[/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 gioi"[/color][color=#007700]); }}[/color]
</div>
</div>
-
03-03-2014, 07:00 AM #76Junior Member
- Ngày tham gia
- Feb 2015
- Bài viết
- 0
import java.util.scanner:
public class diemtrungbinh {
public static void main(string[] args) {
string hoten;
int namsinh;
float t;
float l;
float h;
scanner nhaplenh=new scanner(system.in);
system.out.println("họ và tên :");
hoten=nhaplenh.nextline();
system.out.println("năm sinh :");
namsinh=nhaplenh.nextint();
system.out.println("điểm toán lý hóa lần lượt là :");
t=nhaplenh.nextfloat();
h=nhaplenh.nextfloat();
l=nhaplenh.nextfloat();
float dtb=(t + l+ h)/3;
system.out.println("dtb"+dtb);
if (dtb>=8){
system.out.println("học lực giỏi ");
}else if (dtb>=6){
system.out.println("học lực khá");
}else{
system.out.println("học lực trung bình");
}
}
}
[/code]
-
03-03-2014, 07:00 AM #77Junior Member
- Ngày tham gia
- Dec 2014
- Bài viết
- 3
nộp bài thầy ơi. thầy chưa chấm cho em bài nào hết hic hic:
<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 baitap7[/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]bai1 [/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]double toan[/color][color=#007700], [/color][color=#0000bb]ly[/color][color=#007700], [/color][color=#0000bb]hoa[/color][color=#007700], [/color][color=#0000bb]diemtb[/color][color=#007700]; [/color][color=#0000bb]string hovaten[/color][color=#007700]; [/color][color=#0000bb]int namsinh[/color][color=#007700]; [/color][color=#0000bb]string hovaten[/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 vào họ và tên sinh viên: "[/color][color=#007700]); [/color][color=#0000bb]hovaten [/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 vào năm sinh: "[/color][color=#007700]); [/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); if ([/color][color=#0000bb]namsinh [/color][color=#007700]< [/color][color=#0000bb]1900[/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]"sai năm sinh"[/color][color=#007700]); } else { [/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]toan [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); if ([/color][color=#0000bb]toan [/color][color=#007700]> [/color][color=#0000bb]10 [/color][color=#007700]|| [/color][color=#0000bb]toan [/color][color=#007700]< [/color][color=#0000bb]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]"sai điểm toán"[/color][color=#007700]); } else { [/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]ly [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); if ([/color][color=#0000bb]ly [/color][color=#007700]> [/color][color=#0000bb]10 [/color][color=#007700]|| [/color][color=#0000bb]ly [/color][color=#007700]< [/color][color=#0000bb]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]"sai điểm lý"[/color][color=#007700]); } else { [/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]hoa [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); if ([/color][color=#0000bb]hoa [/color][color=#007700]> [/color][color=#0000bb]10 [/color][color=#007700]|| [/color][color=#0000bb]hoa [/color][color=#007700]< [/color][color=#0000bb]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]"sai điểm hóa"[/color][color=#007700]); } else { [/color][color=#0000bb]diemtb [/color][color=#007700]= [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]round[/color][color=#007700]((([/color][color=#0000bb]toan [/color][color=#007700]+ [/color][color=#0000bb]ly [/color][color=#007700]+ [/color][color=#0000bb]hoa[/color][color=#007700]) / [/color][color=#0000bb]3[/color][color=#007700]) * [/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]pow[/color][color=#007700]([/color][color=#0000bb]10[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) / ([/color][color=#0000bb]math[/color][color=#007700].[/color][color=#0000bb]pow[/color][color=#007700]([/color][color=#0000bb]10[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700]));[/color][color=#ff8000]/*chỗ này làm tròn số*/ [/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 là: " [/color][color=#007700]+ [/color][color=#0000bb]diemtb[/color][color=#007700]); if ([/color][color=#0000bb]diemtb [/color][color=#007700]>= [/color][color=#0000bb]8 [/color][color=#007700]&& [/color][color=#0000bb]diemtb [/color][color=#007700]<= [/color][color=#0000bb]10[/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]"sinh viên này đạt loại giỏi"[/color][color=#007700]); } if ([/color][color=#0000bb]diemtb [/color][color=#007700]< [/color][color=#0000bb]8 [/color][color=#007700]&& [/color][color=#0000bb]diemtb [/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]"sinh viên này xếp loại khá"[/color][color=#007700]); } if ([/color][color=#0000bb]diemtb [/color][color=#007700]< [/color][color=#0000bb]6.5 [/color][color=#007700]&& [/color][color=#0000bb]diemtb [/color][color=#007700]>= [/color][color=#0000bb]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]"sinh viên này học trung bình"[/color][color=#007700]); } if ([/color][color=#0000bb]diemtb [/color][color=#007700]< [/color][color=#0000bb]5[/color][color=#007700]) { [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"sinh viên này học yếu quá"[/color][color=#007700]); } } } } } }}[/color]
</div>
</div>
-
03-25-2014, 07:00 AM #78Junior Member
- Ngày tham gia
- Aug 2015
- Bài viết
- 0
bài này qua lâu rồi nhưng giờ mới biết đến khóa học nên mới tham khảo tới đây. mình có 1 thắc mắc về việc bắt lỗi năm sinh các bạn chỉ bắt lỗi age >0 chứ không thấy bắt lỗi nhập sai dữ liệu vd nhập vào abcxyz. ai biết cách bắt lỗi này thì chỉ dùm mình với.
-
03-30-2014, 07:00 AM #79Junior Member
- Ngày tham gia
- Nov 2014
- Bài viết
- 3
Mã:public class bai1 { public static void main(string[] args) { string hoten; int namsinh; double diemtoan, diemly, diemhoa, dtb; scanner in = new scanner(system.in); system.out.println("nhap thong tin cho sinh vien:"); system.out.print("ho ten:"); hoten = in.nextline(); system.out.print("nam sinh:"); namsinh = in.nextint(); system.out.print("diem hoa:"); diemhoa = in.nextdouble(); system.out.print("diem ly:"); diemly= in.nextdouble(); system.out.print("diem toan:"); diemtoan = in.nextdouble(); dtb =0.0; dtb = (diemhoa+ diemly + diemtoan)/3; if(dtb < 7.0) { system.out.println("hoc luc trung binh"); }else{ if(dtb <= 8.0) system.out.println("hoc luc kha"); else system.out.println("hoc luc gioi"); } } }
-
04-14-2014, 07:00 AM #80Junior Member
- Ngày tham gia
- Jun 2014
- 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 PHP:[color=#000000]
package chapter7[/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]/**** @author quangminh*/[/color][color=#007700]public class [/color][color=#0000bb]chapter7 [/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]string hoten[/color][color=#007700]; [/color][color=#0000bb]long namsinh[/color][color=#007700]; [/color][color=#0000bb]float tb[/color][color=#007700], [/color][color=#0000bb]toan[/color][color=#007700], [/color][color=#0000bb]ly[/color][color=#007700], [/color][color=#0000bb]hoa[/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]"nhap ho va ten: "[/color][color=#007700]); [/color][color=#0000bb]hoten [/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]"nhap nam sinh: "[/color][color=#007700]); [/color][color=#0000bb]namsinh [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextlong[/color][color=#007700](); if ([/color][color=#0000bb]namsinh [/color][color=#007700]<= [/color][color=#0000bb]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]"nhap sai nam sinh"[/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]"nhap diem toan, ly, hoa: "[/color][color=#007700]); [/color][color=#0000bb]toan [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); [/color][color=#0000bb]ly [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); [/color][color=#0000bb]hoa [/color][color=#007700]= [/color][color=#0000bb]nhapdulieu[/color][color=#007700].[/color][color=#0000bb]nextfloat[/color][color=#007700](); if((([/color][color=#0000bb]toan [/color][color=#007700]< [/color][color=#0000bb]0[/color][color=#007700]) || ([/color][color=#0000bb]toan [/color][color=#007700]> [/color][color=#0000bb]10[/color][color=#007700])) || (([/color][color=#0000bb]ly [/color][color=#007700]< [/color][color=#0000bb]0[/color][color=#007700]) || ([/color][color=#0000bb]ly [/color][color=#007700]> [/color][color=#0000bb]10[/color][color=#007700])) || (([/color][color=#0000bb]hoa [/color][color=#007700]< [/color][color=#0000bb]0[/color][color=#007700]) || ([/color][color=#0000bb]hoa [/color][color=#007700]>[/color][color=#0000bb]10[/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 diem"[/color][color=#007700]); } else { [/color][color=#0000bb]tb [/color][color=#007700]= (float) ([/color][color=#0000bb]toan [/color][color=#007700]+ [/color][color=#0000bb]ly [/color][color=#007700]+ [/color][color=#0000bb]hoa[/color][color=#007700]) / [/color][color=#0000bb]3[/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 3 mon: " [/color][color=#007700]+ [/color][color=#0000bb]tb[/color][color=#007700]); if ([/color][color=#0000bb]tb [/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]"hoc luc yeu"[/color][color=#007700]); } else { if ([/color][color=#0000bb]tb [/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]"hoc luc trung binh"[/color][color=#007700]); } else { if([/color][color=#0000bb]tb [/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]"hoc luc kha"[/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]"hoc luc gioi"[/color][color=#007700]); } } } } } } }[/color]
</div>
</div>
Khu dự án Diamond Alnata Plus phát triển bởi Gamuda Land thiết kế hợp lý nằm trung tâm thông gió tự nhiên. Diamond Alnata Plus Tân Phú thiết kế hợp lý sống đích thực ngay giữa trung tâm. Căn hộ cách...
Khu dự án Diamond Alnata Plus giáp trung tâm