迷LOVEの人♂笑℅`笑
BlogJava
首頁
新隨筆
聯系
聚合
管理
posts - 14, comments - 7, trackbacks - 0
java學生屬性輸出小程序
要求:寫一java小程序,要求輸出姓名,班級、年齡、分數、等級
創建三個類Student,StudentText,Text具體程序為:
package
com.dr.student;
public
class
Student
{
private
String name;
private
String department;
private
int
age;
private
int
score;
private
int
level;
/** */
/**
*
@return
the name
*/
public
String getName()
{
return
name;
}
/** */
/**
*
@param
name the name to set
*/
public
void
setName(String name)
{
this
.name
=
name;
}
/** */
/**
*
@return
the department
*/
public
String getDepartment()
{
return
department;
}
/** */
/**
*
@param
department the department to set
*/
public
void
setDepartment(String department)
{
this
.department
=
department;
}
/** */
/**
*
@return
the age
*/
public
int
getAge()
{
return
age;
}
/** */
/**
*
@param
age the age to set
*/
public
void
setAge(
int
age)
{
this
.age
=
age;
}
/** */
/**
*
@return
the score
*/
public
int
getScore()
{
return
score;
}
/** */
/**
*
@param
score the score to set
*/
public
void
setScore(
int
score)
{
this
.score
=
score;
}
/** */
/**
*
@return
the level
*/
public
int
getLevel()
{
return
level;
}
/** */
/**
*
@param
level the level to set
*/
public
void
setLevel(
int
level)
{
this
.level
=
level;
}
}
package
com.dr.student;
public
class
StudentText
{
public
static
Student[] getStudent()
{
Student[] stuArr
=
new
Student[
5
];
//
##############################################
Student stu1
=
new
Student();
stu1.setName(
"
rose
"
);
stu1.setDepartment(
"
生命科學系
"
);
stu1.setScore(
90
);
stu1.setAge(
23
);
stu1.setLevel(
1
);
stuArr[
0
]
=
stu1;
//
#################################################
Student stu2
=
new
Student();
stu2.setName(
"
lucky
"
);
stu2.setDepartment(
"
計算機科學系
"
);
stu2.setScore(
89
);
stu2.setAge(
24
);
stu2.setLevel(
2
);
stuArr[
1
]
=
stu2;
//
#################################################
Student stu3
=
new
Student();
stu3.setName(
"
LiLi
"
);
stu3.setDepartment(
"
中文系
"
);
stu3.setScore(
98
);
stu3.setAge(
20
);
stu3.setLevel(
3
);
stuArr[
2
]
=
stu3;;
//
####################################################
Student stu4
=
new
Student();
stu4.setName(
"
mery
"
);
stu4.setDepartment(
"
數信系
"
);
stu4.setScore(
97
);
stu4.setAge(
23
);
stu4.setLevel(
2
);
stuArr[
3
]
=
stu4;
//
###############################################
Student stu5
=
new
Student();
stu5.setName(
"
xiaoxiao
"
);
stu5.setDepartment(
"
計算機科學系
"
);
stu5.setScore(
99
);
stu5.setAge(
21
);
stu5.setLevel(
1
);
stuArr[
4
]
=
stu5;
return
stuArr;
}
public
static
void
getScore(
int
i)
{
switch
(i)
{
case
(
9
):
{
System.out.println(
"
等級為A
"
);
break
;
}
case
(
8
):
{
System.out.println(
"
等級為B
"
);
break
;
}
case
(
7
):
{
System.out.println(
"
等級為C
"
);
break
;
}
case
(
6
):
{
System.out.println(
"
等級為D
"
);
break
;
}
default
:
{
System.out.println(
"
等級為E
"
);
break
;
}
}
}
}
package
com.dr.student;
public
class
Test
{
public
static
void
main(String[] args)
{
Student[] stu
=
StudentText.getStudent();
for
(
int
i
=
0
;i
<
stu.length;i
++
)
{
if
(stu[i]
!=
null
)
{
System.out.println(
"
我叫
"
+
stu[i].getName()
+
stu[i].getDepartment()
+
"
---今年
"
+
stu[i].getAge()
+
"
---本次分數為
"
+
stu[i].getScore()
+
"
---水平為
"
+
stu[i].getLevel());
int
j
=
stu[i].getScore()
/
10
;
StudentText.getScore(j);
}
}
}
}
posted on 2010-10-09 08:38
迷人笑笑
閱讀(167)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Copyright ©2025 迷人笑笑 Powered By:
博客園
模板提供:
滬江博客
<
2010年10月
>
日
一
二
三
四
五
六
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(13)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2011年1月 (1)
2010年11月 (4)
2010年10月 (9)
文章檔案
2010年11月 (2)
搜索
最新評論
1.?re: java中構造方法和方法全面解析
為什么非要調用父類的構造方法
--zjy
2.?re: java-醫院病人排隊掛號醫生叫號簡潔小系統
代碼不全 QueueServer 沒有
--sss
3.?re: Java中thread類與Runnable接口的區別
受教了
--李大明
4.?re: java中消費者與生產者的問題實例解析
樓主有沒有搞錯啊 你的最后那個截圖后面不還是亂的嗎 不是一個一個交替輸出的啊
--aben
5.?re: java堆棧存取實例小講解
@閆佳
上面有插入代碼--呵呵---
--迷人笑笑
閱讀排行榜
1.?java中構造方法和方法全面解析(39161)
2.?java中String s = new String("abc")創建了幾個對象?!(10653)
3.?java銀行排隊系統簡單程序(3768)
4.?java-醫院病人排隊掛號醫生叫號簡潔小系統(3464)
5.?java中消費者與生產者的問題實例解析(2159)
評論排行榜
1.?java堆棧存取實例小講解(3)
2.?java中構造方法和方法全面解析(1)
3.?java中消費者與生產者的問題實例解析(1)
4.?java-醫院病人排隊掛號醫生叫號簡潔小系統(1)
5.?java銀行排隊系統簡單程序(0)
主站蜘蛛池模板:
日韩精品在线免费观看
|
国产精品亚洲综合久久
|
亚洲午夜国产片在线观看
|
免费人成视网站在线观看不卡
|
四虎在线播放免费永久视频
|
国产午夜精品理论片免费观看
|
久久国产精品成人免费
|
精品久久久久国产免费
|
又大又硬又爽免费视频
|
亚洲AV网一区二区三区
|
www一区二区www免费
|
亚洲毛片免费观看
|
四虎永久免费地址在线观看
|
www亚洲精品久久久乳
|
国产一区二区三区免费在线观看
|
色噜噜噜噜亚洲第一
|
一本久到久久亚洲综合
|
亚洲精品第五页中文字幕
|
狠狠入ady亚洲精品
|
亚洲电影日韩精品
|
无码AV片在线观看免费
|
成人爱做日本视频免费
|
亚洲av不卡一区二区三区
|
亚洲精品一卡2卡3卡四卡乱码
|
a级毛片免费播放
|
亚洲成a人一区二区三区
|
亚洲一区二区三区免费
|
日本亚洲成高清一区二区三区
|
黄色一级毛片免费看
|
99精品一区二区免费视频
|
精品国产日韩亚洲一区
|
亚洲精华国产精华精华液好用
|
狠狠色伊人亚洲综合成人
|
亚洲国产精品精华液
|
亚洲精品无码久久久久AV麻豆
|
欧美色欧美亚洲另类二区
|
久久久久国色AV免费看图片
|
国产精品亚洲五月天高清
|
日韩一级视频免费观看
|
国产视频精品免费视频
|
国产国拍精品亚洲AV片
|