Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Program Create a version of the stars program to print a configuration of t

ID: 672552 • Letter: J

Question

Java Program

Create a version of the stars program to print a configuration of the stars just like in the picture. I am not sure of my loop knowledge and its getting some interesting errors. Thanks for any helpful insight.

*Demonstrates the use of nested for loops. eauthor Java F public class Stars * Prints a triangle shape using asterisk (star) characters. param args public static void main (String[] args) final int MAX-ROWS = 10; for (int row= MAX ROWS; row > 0 ; row--) for (int star = 0; star

Explanation / Answer

public class Stars
{
/**
* Prints a triangle shape using asterisk (star) characters.
* @param args
*/
public static void main (String[] args)
{
final int MAX_ROWS = 10;

for (int row = 1; row <= MAX_ROWS ; row++)
{
       //spaces needs to inserted
       for(int space = 0 ; space < MAX_ROWS - row ; space++)
           System.out.print(" ");
for (int star = 0; star < row; star++)
System.out.print ("*");

System.out.println();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote