jsp for shooting stars with a door

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

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

I created a jsp statement with the result value as shown above.

<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Star</title>
</head>
<body>
<%
for (int i = 0; i < 10; i++) {
    for (int j = 1; j < 10 - i; j++) {
        out.print(" ");
    }
    for (int j = 0; j < i * 2 + 1; j++) {
        out.print("*");
    }
    out.println("<br>");
}
%>
</body>
</html>

The code I made has the result of a rectangular triangle, not an equilateral triangle. What is the problem? I'd appreciate your help.

jsp

2022-09-20 10:54

1 Answers

Try writing &nbsp; instead of ".


2022-09-20 10:54

If you have any answers or tips


© 2022 pinfo. All rights reserved.