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

This is suppose to be done in Java Output: * ** *** **** ***** ****** ******* **

ID: 3875816 • Letter: T

Question

This is suppose to be done in Java

Output:

*

**

***

****

*****

******

*******

********

*********

**********

**********

********

********

*******

******

*****

****

***

**

*

**********

*********

********

*******

******

*****

****

***

**

*

*

**

***

****

*****

******

*******

********

*********

**********

Problem Statement: Using the Eclipse IDE, write a Java program that displays the following patterns separately, one below the other, on the computer screen. See the Sample Output below. Use for loops to generate the patterns. After your program is capable of printing the patterns with a width of 10 characters (as in the sample output),change your program so that a single numerical value in your code controls the width of the patterns. That is, changing a single ”10" to "20" in ONE place in your code causes the patterms to be a width of 20 characters (which means you should use a variable to denote the maximum width). Other requirements ) must be printed individually by a single statement (inside All asterisks a loop) of the form System.out,print A statement of the form System.out.printin0; can be used to move to the next line. A statement of the form System.out.print(" "); can be used to display a single space for the last two patterns. There should be no other output statements in the program.

Explanation / Answer

class Main{
public static void main(String[] args) {
  
// here modifying n will modify the number of stars and lines printed
int n = 10, i, j;
  
// looing for n times for n lines
for(i=1; i<=n; i++)
{
// looing for i times for i stars
for(j=1; j<=i; j++)
{
// printing star
System.out.print("*");
}
// printing a line
System.out.println();
}
System.out.println();
for(i=n; i>=1; i--)
{
for(j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
System.out.println();
System.out.println();
  
// second pattern
for(i=n; i>=1; i--)
{
for(j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
System.out.println();
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

/*SAMPLE OUTPUT for n=10
*
**
***
****
*****
******
*******
********
*********
**********

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


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

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

SAMPLE OUTPUT for n=20

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

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


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

*
**
***
****
*****
******
*******
********
*********
**********
***********
************
*************
**************
***************
****************
*****************
******************
*******************
********************
*/

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