1. 编写程序,用数组实现乘法小九九的存储和输出。【提示:采用多个一维数组。】 public class Multipation {
public static void main(String[] args) { // TODO Auto-generated method stub int x[][]=new int[9][9]; for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ if(i>=j){ int m=i+1; }
}
}
int n=j+1;
x[i][j]=m*n;
System.out.print(m+\+n+\+x[i][j]);
}
}
System.out.println();
2. 定义一个类Student,属性为学号、姓名和成绩;方法为增加记录SetRecord和得到记录GetRecord。SetRecord给出学号、姓名和成绩的赋值,GetRecord通过学号得到考生的成绩。
public class Student { }
/**
* @param args */
private int ID; private String name; private float score;
public void SetRecord(int ID,String name,float score){ }
public float getRecord(int ID){ }
if(ID==this.ID) return this.score; else return -1; }
// TODO Auto-generated method stub Student s=new Student(); s.SetRecord(0,\,100); float Sco=s.getRecord(0); System.out.print(Sco); this.ID=ID; this.name=name; this.score=score;
public static void main(String[] args) {
3. 给出上题中设计类的构造函数,要求初始化一条记录(学号、姓名、成绩)。
4. public class Student { 5. 6. /**
7. * @param args 8. */
9. private int ID; 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. }
public static void main(String[] args) { }
// TODO Auto-generated method stub Student s=new Student(0,\,12); //s.SetRecord(0,\ float Sco=s.getRecord(0); System.out.print(Sco); private String name; private float score;
Student(int ID,String name,float score){ }
public void SetRecord(int ID,String name,float score){ }
public float getRecord(int ID){
if(ID==this.ID) return this.score; else return -1; }
this.ID=ID; this.name=name; this.score=score;
this.ID=0; this.name=\; this.score=65;