11.14总结

1.
public class Summary {

public static void main(String[] args) {
    // TODO Auto-generated method stub
     int summary=0;
     int i=0;
     while(i<100){
         i++;
         summary+=i;
     }
     System.out.println("1+2+3+...99+100="+summary);
    }


}

2.
public class TestArray2
{
public static void main(String[] args)
{
double arr[]={1.1,2.2,3.3,4.4,5.5};
System.out.println(“第一个变量为: “+arr[0]);
System.out.println(“第五个变量为: “+arr[4]);

}

}
3.
public class Student {
private String name ;
int age;
boolean sex;
int score;

public Student(String name, int age, boolean sex, int score) {
    super();
    this.name = name;
    this.age = age;
    this.sex = sex;
    this.score = score;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getAge() {
    return age;
}
public void setAge(int age) {
    this.age = age;
}
public String getSex() {
    if (sex==true) {
        return "男";
    }
    return "女";
}
public void setSex(boolean sex) {
    this.sex = sex;
}
public int getScore() {
    return score;
}
public void setScore(int score) {
    this.score = score;
}
public static void main(String[] args) {
    Student s= new Student("黄世仁", 24, true, 59);
    System.out.println("姓名:"+s.getName());
    System.out.println("年龄:"+s.getAge());
    System.out.println("性别:"+s.getSex());
    System.out.println("分数:"+s.getScore());
}

}