Answer to Question #23758 in Java | JSP | JSF for linda

Question #23758
Write a program that displays the following pattern: * *** ***** ******* ***** *** * Output. Seven lines of output as follows: The first consists of 3 spaces followed by a star. The second line consists of 2 spaces followed by a 3 stars. The third consists of one space followed by 5 stars, and the fourth consists just of 7 stars. The fifth line is identical to third, th sixth to the second and the seventh to the first. CLASS NAMES. Your program class should be called StarPattern
1
Expert's answer
2013-02-05T11:41:57-0500
public class StarPattern {

publicstatic void main(String[] args) {
finalint rows = 7;
intspaces = rows/2;
intstars = 1;
for(inti = 0; i < rows; i ++){
for(intj = 0; j < spaces; j ++){
System.out.print("");
}
for(intj = 0; j < stars; j ++){
System.out.print("*");
}
System.out.println();
if(i< rows/2){
spaces--;
stars+= 2;
}
else{
spaces++;
stars-= 2;
}
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal