Question
* *** ***** ******* ***** *** * Write a program that displays the followingpattern: Output . Seven lines of output as follows: The first consists
*
***
*****
*******
*****
***
*
Write a program that displays the followingpattern:
Output . Seven lines of output as follows: The first consists of3 spaces followed by a star. The second line consists of 2 spacesfollowed by a 3 stars. The third consists of one space followed by5 stars, and the fourth consists just of 7 stars. The fifth line isidentical to third, th sixth to the second and the seventh to thefirst.
CLASS NAMES. Your program class should be called StarPattern
I NEED iIT TONIGHT! IT MUS TBE In JAVA PROGRAMMING......I triedbut getting a lot of errors..when i enter it in the myprogramminglab -BADLY NEED HELP!
public class StarPattern
{ public static 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; } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started