JAVA题:定义People及其对象
定义一个类People,成员变量有姓名,出生日期,性别,身高,体重等,成员方法有计算年龄,并创建该类的对象.
import java.util.Scanner;
public class People
private int age;
private double weight;
private Date birthday;
public People (int n)
this.age = new int[n];
this.weight = new double[n];
this.birthday = new Date[n];
Scanner in = new Scanner(System.in);
{
age[n] = in.nextInt();
weight [n] = in.nextDouble();
birthday[n] = new Date(in.nextInt(),in.nextInt(),in.nextInt());
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>