JAVA题:定义People及其对象

文章作者 100test 发表时间 2007:03:26 17:58:29
来源 100Test.Com百考试题网


定义一个类People,成员变量有姓名,出生日期,性别,身高,体重等,成员方法有计算年龄,并创建该类的对象.

import java.util.Scanner.

public class People
{
private int[] age.
private double[] height.
private double[] weight.
private String[] sex.
private Date[] birthday.

public People (int n)
{
this.age = new int[n].
this.height = new double[n].
this.weight = new double[n].
this.sex = new String[n].
this.birthday = new Date[n].

Scanner in = new Scanner(System.in).
for (int i = 0. i< n. i )
{
System.out.println("Please input the age, height, weight, sex,and birthday").
age[n] = in.nextInt().
height [n] = in.nextDouble().
weight [n] = in.nextDouble().
sex[n] = in.next().
birthday[n] = new Date(in.nextInt(),in.nextInt(),in.nextInt()).
}
}

}



相关文章


Java认证模拟题及分析5
Java认证模拟题及分析3
Java认证模拟题及分析1
JAVA题:定义People及其对象
Java认证模拟题及分析2
排序和金额转换·两道JAVA编程题及答案
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛