100分求两个简单的程序。 帮你写会被楼上的兄弟唾弃,怕怕阿 ^^楼主加油阿:其实很简单的,主要看你SQL写得咋样 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下内容粘贴到OutputStudents.java后编译运行, 写的不规范的地方高手来指正一下.class Student { // 定义Student属性, sex = true 代表男 private String name; private boolean sex; private int age; private int score; // 通过构造函数设置属性值 public Student (String name, boolean sex, int age, int score) { this.name = name; this.sex = sex; this.age = age; this.score = score; } // 定义设置属性值方法 public void setName(String name) { this.name = name; } public void setSex(boolean sex) { this.sex = sex; } public void setAge(int age) { this.age = age; } public void setScore(int score) { this.score = score; } // 定义取得属性值方法 public String getName() { return name; } public boolean getSex() { return sex; } public int getAge() { return age; } public int getScore() { return score; }}public class OutputStudents { // 保存所有学生信息 private Student[] stds; // 初始化学生信息,方便期间用构造函数设置属性值 public OutputStudents() { stds = new Student[12]; stds[0] = new Student("Andy", false, 23, 80); stds[1] = new Student("Jack", true, 24, 70); stds[2] = new Student("Tom", true, 28, 77); stds[3] = new Student("Tinna", false, 26, 88); stds[4] = new Student("Mark", true, 23, 65); stds[5] = new Student("Ross", true, 27, 68); stds[6] = new Student("William", true, 22, 72); stds[7] = new Student("Rachel", false, 25, 81); stds[8] = new Student("Joey", true, 28, 67); stds[9] = new Student("Monica", false, 23, 65); stds[10] = new Student("Phoebe", false, 22, 80); stds[11] = new Student("Chandler", true, 26, 75); } public static void main(String[] args) { // 初始化学生信息 OutputStudents opstd = new OutputStudents(); // 打印优秀学生名单 System.out.println("优秀学员的名单:"); for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() > 80) { System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore()); } } System.out.println(); // 打印成绩良好的男学生名单 System.out.println("良好男学员的名单:"); for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() > 70 && opstd.stds[i].getSex()) { System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore()); } } System.out.println(); // 打印年龄低于等于25并且70分以下的女学生 System.out.println("年龄<=25并且70分以下的女学生名单:"); for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() < 70 && opstd.stds[i].getAge() <= 25 && opstd.stds[i].getSex() == false) { System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore()); } } }} 如何使用正则表达式对文章分段 如何打开文件??? 定时器出错?? 求JAVA源码(两人在线游戏)(200分) 请问下面的操作符怎么改? 各位大哥,请教关于system.out的问题 非常简单的问题 JAVA运行错误?帮帮小弟! 请问怎样在WinXP或者是Win2000下安装和调试JDK? 小虾求助!! Windows2000平台上Java程序连接oracle9i的简单问题 java程序的美观问题……
class Student {
// 定义Student属性, sex = true 代表男 private String name;
private boolean sex;
private int age;
private int score; // 通过构造函数设置属性值
public Student (String name, boolean sex, int age, int score) {
this.name = name;
this.sex = sex;
this.age = age;
this.score = score;
}
// 定义设置属性值方法 public void setName(String name) {
this.name = name;
} public void setSex(boolean sex) {
this.sex = sex;
} public void setAge(int age) {
this.age = age;
} public void setScore(int score) {
this.score = score;
} // 定义取得属性值方法 public String getName() {
return name;
} public boolean getSex() {
return sex;
} public int getAge() {
return age;
} public int getScore() {
return score;
}
}public class OutputStudents {
// 保存所有学生信息
private Student[] stds;
// 初始化学生信息,方便期间用构造函数设置属性值
public OutputStudents() { stds = new Student[12];
stds[0] = new Student("Andy", false, 23, 80);
stds[1] = new Student("Jack", true, 24, 70);
stds[2] = new Student("Tom", true, 28, 77);
stds[3] = new Student("Tinna", false, 26, 88);
stds[4] = new Student("Mark", true, 23, 65);
stds[5] = new Student("Ross", true, 27, 68);
stds[6] = new Student("William", true, 22, 72);
stds[7] = new Student("Rachel", false, 25, 81);
stds[8] = new Student("Joey", true, 28, 67);
stds[9] = new Student("Monica", false, 23, 65);
stds[10] = new Student("Phoebe", false, 22, 80);
stds[11] = new Student("Chandler", true, 26, 75);
} public static void main(String[] args) {
// 初始化学生信息
OutputStudents opstd = new OutputStudents();
// 打印优秀学生名单
System.out.println("优秀学员的名单:");
for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() > 80) {
System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore());
}
}
System.out.println(); // 打印成绩良好的男学生名单
System.out.println("良好男学员的名单:");
for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() > 70 && opstd.stds[i].getSex()) {
System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore());
}
}
System.out.println(); // 打印年龄低于等于25并且70分以下的女学生
System.out.println("年龄<=25并且70分以下的女学生名单:");
for (int i = 0; i < opstd.stds.length; i++) { if (opstd.stds[i].getScore() < 70 && opstd.stds[i].getAge() <= 25 && opstd.stds[i].getSex() == false) {
System.out.println(" " + opstd.stds[i].getName() + " " + opstd.stds[i].getScore());
}
} }
}