java第一次作业
1.
package Class; public class Class1 { public static void main(String[] args) { // TODO Auto-generated method stub Student s1=new Student(173230207, 03, "刘德璞"); s1.shuchu(); } } class Student{ int xuehao,banji; String xingming; public Student(int xuehao, int banji, String xingming) { super(); this.xuehao = xuehao; this.banji = banji; this.xingming = xingming; } void shuchu(){ System.out.println("学号:"+xuehao+" "+"班级:"+banji+" "+"姓名:"+xingming); } }
2.
package Class; public class Class1 { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(" "+" "+" "+" "+"*"+" "+" "+" "+" "); System.out.println(" "+" "+"*"+" "+"*"+" "+"*"+" "+" "); System.out.println("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"); System.out.println(" "+" "+"*"+" "+"*"+" "+"*"+" "+" "); System.out.println(" "+" "+" "+" "+"*"+" "+" "+" "+" "); } }
3.
package Class; public class Class1 { public static void main(String[] args) { // TODO Auto-generated method stub Sum s1=new Sum(5, 8); s1.shuchu(); } } class Sum{ int a,b; public Sum(int a, int b) { super(); this.a = a; this.b = b; } void shuchu(){ int sum; sum=a*a+b*b; System.out.println(sum); } }