关于Java的所有文章StudentManager的代码:

package pack1;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Scanner;
import pack1.Address;
import pack1.Student;
public class StudentManager1_1
{
static void input(Student a[],int i)
{
Scanner in=new Scanner(System.in);
System.out.println("请输入学生姓名:");
String xm=in.next();
System.out.println("请输入学生年龄:");
int nl=in.nextInt();
System.out.println("请输入学生学号:");
String xh=in.next();
a[i]=new Student(nl,xm,xh);
System.out.println("请输入学生家庭所在城市:");
String cs=in.next();
System.out.println("请输入学生家庭所在小区和单元:");
String dy=in.next();
System.out.println("请输入邮政编码:");
int yzbm=in.nextInt();
Address dz=new Address(cs,dy,yzbm);
a[i].setAddress(dz);
System.out.println("请输入学生出生年.月.日:");
int nian=in.nextInt();
int yue=in.nextInt();
int ri=in.nextInt();
GregorianCalendar rq=new GregorianCalendar(nian,yue-1,ri);
Date csrq=rq.getTime();
a[i].setBirthDay(csrq);
System.out.println("录入成功!");
}
static void output(Student a[],int x)
{
int b=0;
do{
System.out.println("*********************请选择查询方式****************");
System.out.println("\t\t******1.通过姓名或学号查询********");
System.out.println("\t\t******2.返回主界面 ********");
Scanner in=new Scanner(System.in);
int c=in.nextInt();
switch(c)
{
case 1:
{
System.out.println("请输入要查找的学生的姓名或学号:");
String info=in.next();
int i;
for(i=0;i {
if(a[i].getName().equalsIgnoreCase(info))
{a[i].printStudent();break;}
if(a[i].getNumber().equalsIgnoreCase(info))
{a[i].printStudent();break;}
}
if(i==x)
System.out.println("查无此人!");
break;
}
case 2:b=1;
}
}while(b==0);
}
public static void main(String[] args)
{
Student a[]=new Student[100];
int i=0;
do{
System.out.println("*********************欢迎使用学生基本信息管理系统****************");
System.out.println("\t\t******1.输入学生信息********");
System.out.println("\t\t******2.显示学生信息********");
System.out.println("\t\t******3.退出系统 ********");
Scanner in=new Scanner(System.in);
int c=in.nextInt();
switch(c)
{
case 1:
{input(a,i);i++;break;}
case 2:
{output(a,i);break;}
case 3:
System.out.println("谢谢使用,再见!");
System.exit(0);
}
}while(true);
}
}

Student的代码:

package pack1;
import java.text.SimpleDateFormat;
import java.util.Date;

import pack1.Address;

public class Student {

int age;

private String number;

private String name;

private Date birthDay;

private Address address;

public Student(int age,String name,String number)

{

this.age=age;

this.name=name;

this.number=number;

}

public int getAge() {

return age;

}

public String getNumber() {

return number;

}

public void setNumber(String number) {

this.number = number;

}

public void setAge(int age) {

this.age = age;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Date getBirthDay()

{

return birthDay;

}

public void setBirthDay(Date birthDay)

{

this.birthDay=birthDay;

}

public Address getAddress()

{

return address;

}

public void setAddress(Address address) {

this.address = address;

}

public void printStudent(){

System.out.println("------------------------");

System.out.println("该学生的基本信息是:");

System.out.println("姓名:"+name);

System.out.println("年龄:"+age);

System.out.println("学号:"+number);

address.printAddress();

SimpleDateFormat df=new SimpleDateFormat("yyyy年MM月dd日");

System.out.println("出生年月:"+df.format(birthDay));

}

}

Address的代码:

package pack1;
public class Address
{

private String city;

private String home;

private int postCode;

public Address(String city,String home,int postCode)

{

this.city=city;

this.home=home;

this.postCode=postCode;

}

public void printAddress()

{

System.out.println("家庭住址:"+city+home);

System.out.println("邮政编码:"+postCode);

}

}