项目 内容
课程班级博客链接 19级信计班(本)
这个作业要求链接 java第二周作业
博客名称 1903021138-陈红—Java第二周作业-代码和截图
要求 每道题要有题目,代码(使用插入代码,不会插入代码的自己查资料解决,不要直接截图代码!!),截图(只截运行结果)

题目1:

输出以下图形

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

代码:

public class CH{

/**
* @param args
*/
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(" * ");
}
}

插入:

public class CH{

/**
 * @param args
 */
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("  *  ");
}
}

截屏:

 

 

题目2:

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

代码:

public class CHZVL {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a=5,b=8;
System.out.println("a*a+b*b="+(a*a+b*b));
}
}

插入:

ublic class CHZVL {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub    
    int a=5,b=8;
    System.out.println("a*a+b*b="+(a*a+b*b));
}
}

截屏:

 

posted on 2022-03-13 18:57  chzwl  阅读(21)  评论(0编辑  收藏  举报