「java显示图案」java显示图案java

博主:adminadmin 2023-03-18 15:21:09 358

今天给各位分享java显示图案的知识,其中也会对java显示图案java进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java语言程序设计 编写一个程序 显示下面的图案 显示以下表格 这两题

public class Demo1 {

public static void main(String[] args) throws Exception {

System.out.println("     J     A     V     V     A");

System.out.println("     J    A A     V   V     A A");

System.out.println("J    J   AAAAA     V V     AAAAA");

System.out.println(" J J    A     A     V     A     A");

}

}

public class Demo2 {

public static void main(String[] args) throws Exception {

// -左对齐,5表示输出元素占5个单位,s表示输出的是字符串,%n是换行

System.out.format("%-5s%-5s%-5s%n", "a", "a^2", "a^3");

for (int i = 1; i = 4; i++) {

// 同理,%d 表示输出的是整数

System.out.format("%-5d%-5d%-5d%n", i, i * i, i * i * i);

}

}

}

分别运行的结果:

JAVA中为什么画出的图形没法显示出来?

你这个是代码里面拼写错误了,改成下面的可以显示

class DontStepOnWhitePiece extends JPanel

{

public void paint(Graphics g)   //上面的这里拼写错误,panit

{

super.paint(g);

g.setColor(Color.black);

g.drawRect(0, 0, 100, 100);

}

java代码写完后保存为.java但是桌面上显示的图案不是J

不是显示J图标没关系,不影响它的功能。

如果你想显示为带“J"的图标,得满足以下条件:

1.

机器上安装了JCreator这种java代码编辑器软件;

2.

java源代码文件的默认打开方式是JCreator编辑器,不能是其它编辑器软件;

满足以上两点,保存的.java文件在桌面上就显示”J"图标了。

亲,记得采纳哦!

用java编写程序显示字符编排图案

for (int i = 1; i = 4; i++) {

   for (int j = 1; j = 7; j++) // 打印每行的个数

   {

      if (i == 1 || i == 2) {

         if (j == 7) {

            System.out.print("       J");

         }

      }

      if (i == 3) {

         if (j == 1) {

            System.out.print("J      ");

         }

         if (j == 5) {

            System.out.print("J");

         }

      }

      if (i == 4) {

         if (j == 1) {

            System.out.print("  J  ");

         }

         if (j == 4) {

            System.out.print("J  ");

         }

      }

   }

   for (int j = 1; j = 7; j++) // 打印每行的个数

   {

      if (i == 1  j == 1) {

         System.out.print("      A      ");

      }

      if (i == 2  j == 1) {

         System.out.print("     A A     ");

      }

      if (i == 3  j == 1) {

         System.out.print("    AAAAA    ");

      }

      if (i == 4  j == 1) {

         System.out.print("   A     A   ");

      }

   }

   for (int j = 1; j = 7; j++) // 打印每行的个数

   {

      if (i == 1  j == 1) {

         System.out.print("V     V");

      }

      if (i == 2  j == 1) {

         System.out.print(" V   V ");

      }

      if (i == 3  j == 1) {

         System.out.print("  V V  ");

      }

      if (i == 4  j == 1) {

         System.out.print("   V    ");

      }

   }

   for (int j = 1; j = 7; j++) // 打印每行的个数

   {

      if (i == 1  j == 1) {

         System.out.print("      A      ");

      }

      if (i == 2  j == 1) {

         System.out.print("     A A     ");

      }

      if (i == 3  j == 1) {

         System.out.print("    AAAAA    ");

      }

      if (i == 4  j == 1) {

         System.out.print("  A     A   ");

      }

   }

   System.out.println();

}

怎么样用JAVA编程语言在屏幕上显示一个由星型符号“*”组成的金字塔图案

自己写的,应该能满足你要求了。

public class Triangle {

public static void main(String[] args){

int maxLength = 10; //金字塔的边长,可按你需求修改的

for(int m=1;m2*maxLength;m++){

if(mmaxLength){

printBlanks(maxLength-m);

printStars(2*m-1);

} else {

printBlanks(m-maxLength);

printStars(2*(2*maxLength-m)-1);

}

System.out.println();

}

}

public static void printBlanks(int n){

for(int i=0;in;i++){

System.out.print(" ");

}

}

public static void printStars(int n){

for(int i=0;in;i++){

System.out.print("*");

}

}

}

如何使用java的for的嵌套循环编写程序,显示出如下图案:* ** *** **** ***** ******

使用java的for的嵌套循环编写程序,显示直线递增星号图案和直角三角形星号图案如下:

public class TestD {

public static void main(String[] args){

System.out.println("直线递增型:");

//直线递增型

for(int x=0;x=5;x++){

//每一组打印多少x个星号

for(int y=0;y=x;y++){

System.out.print("*");

}

//不同组以空格隔开

System.out.print(" ");

}

System.out.println();

System.out.println("直角三角形:");

//直角三角形

for(int x=0;x=5;x++){

//每一组打印多少x个星号

for(int y=0;y=x;y++){

System.out.print("*");

}

//不同组不同行需换行

System.out.println("");

}

}

}

结果:

直线递增型:

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

直角三角形:

*

**

***

****

*****

******

关于java显示图案和java显示图案java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。