Java第一周作业

1.输出学号班级和姓名

 1 package chap1;
 2 
 3 public class TestHello {
 4 
 5     public static void main(String[] args) {
 6         // TODO Auto-generated method stub
 7         System.out.println("学号:193230512");
 8         System.out.println("班级:计算机1905");
 9         System.out.println("姓名:李伟康");
10 
11     }
12 
13 }

 

2.输出以下图形

     *
    ***
   *****
    ***
     *

 1 package chap1;
 2 
 3 public class TestHello {
 4 
 5     public static void main(String[] args) {
 6         // TODO Auto-generated method stub
 7         System.out.println("  *\n"+" ***\n"+"*****\n"+" ***\n"+"  *\n");
 8     
 9     }
10 
11 }

 

3.定义两个整型变量a=5  b=8  求平方和并输出

 1 package chap1;
 2 
 3 public class TestHello {
 4 
 5     public static void main(String[] args) {
 6         // TODO Auto-generated method stub
 7         int a=5;
 8         int b=8;
 9         
10         System.out.println(a*a+b*b);
11     
12     }
13 
14 }

posted @ 2021-03-08 13:29  Lwk36  阅读(41)  评论(0编辑  收藏  举报