Tìm kiếm
Latest topics
Top posters
fx (49) | ||||
thanhvu215 (19) | ||||
minhduc2592 (13) | ||||
nucuoithienthan20077 (7) | ||||
biboy (6) | ||||
pengox2912 (2) | ||||
boylangyeu (2) | ||||
sock (2) | ||||
nucuojhanhphuc (2) | ||||
nhongthuy (2) |
Bài tập SINHVIEN
Trang 1 trong tổng số 1 trang
Bài tập SINHVIEN
Hàm main
/*
* To change this template, choose | Templates
* and open the template in the editor.
*/
package bai3;
/**
*
* @author Administrator
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SV s=new SV(1,"son",5);
SV s1=new SV();
s1.nhap();
s.hienThi();
s1.hienThi();
}
}
Hàm con: SINHVIEN
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bai3;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class SV {
int ma;
String ten;
float dtb;
public SV(int m,String t,float d){
this.ma=m; this.ten=t; this.dtb=d;
}
public SV() {
this.ma=0;
this.ten="";
this.dtb=0;
}
public void hienThi(){
System.out.println("ma:" + this.ma);
System.out.println("Ten:" + this.ten);
System.out.println("DTB:" + this.dtb);
}
public void nhap(){
Scanner sc=new Scanner(System.in);
System.out.println("ma:");
this.ma=sc.nextInt();
System.out.println("Ten:");
sc.nextLine();
this.ten=sc.nextLine();
System.out.println("DTB:");
this.dtb=sc.nextFloat();
}
}
/*
* To change this template, choose | Templates
* and open the template in the editor.
*/
package bai3;
/**
*
* @author Administrator
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SV s=new SV(1,"son",5);
SV s1=new SV();
s1.nhap();
s.hienThi();
s1.hienThi();
}
}
Hàm con: SINHVIEN
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bai3;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class SV {
int ma;
String ten;
float dtb;
public SV(int m,String t,float d){
this.ma=m; this.ten=t; this.dtb=d;
}
public SV() {
this.ma=0;
this.ten="";
this.dtb=0;
}
public void hienThi(){
System.out.println("ma:" + this.ma);
System.out.println("Ten:" + this.ten);
System.out.println("DTB:" + this.dtb);
}
public void nhap(){
Scanner sc=new Scanner(System.in);
System.out.println("ma:");
this.ma=sc.nextInt();
System.out.println("Ten:");
sc.nextLine();
this.ten=sc.nextLine();
System.out.println("DTB:");
this.dtb=sc.nextFloat();
}
}
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|
Tue May 21, 2013 8:07 am by NGUOIMIENTAY
» THAY ĐỔI HÌNH ẢNH TRÊN DIỄN ĐÀN ĐI XẤU QUÁ HÀ
Sat Feb 04, 2012 8:36 pm by hongsang
» KỸ NĂNG ĐẠT ĐẾN THÀNH CÔNG - BIẾT CÁCH BÁN HÀNG
Sat Sep 24, 2011 2:05 pm by banhminuong
» Source BT tuần 1
Sun Sep 18, 2011 7:44 pm by nucuoithienthan20077
» 12 Lý do để thử ngay Ubuntu 11.04
Sat Sep 17, 2011 9:57 pm by fx
» Bài tập SINHVIEN
Wed Sep 14, 2011 10:15 pm by fx
» Bom Tan Tuan` 1 ne````
Mon Aug 29, 2011 1:11 pm by nucuojhanhphuc
» TÀI LIỆU KIẾN TRÚC MÁY TÍNH
Mon Aug 29, 2011 12:41 am by minhduc2592
» ĐÔRÊMON CHẾ
Sat Aug 13, 2011 11:31 am by nucuoithienthan20077