1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GenaCL600 [577]
3 years ago
8

I don't understand how to write code for this in Java using nested for loops only. The official question is: write a program tha

t produces the following hourglass figure using nested for loops?

Computers and Technology
1 answer:
Bingel [31]3 years ago
4 0

Answer:

public class Triangle

{

public static void main( String[] args )

{

show( 5 );

}

public static void show( int n )

{

int i,j,k;

for (i = 0; i < n - 1; i++ )

{

for (j = 0; j < i; j++ )

{

System.out.print( " " );

}

for (k = n - i; k > 0; k-- )

{

System.out.print( "* " );

}

System.out.println();

}

for (i = 0; i < n; i++ )

{

for (j = n - i; j > 1; j-- )

{

System.out.print( " " );

}

for (k = 0; k < i + 1; k++ )

{

System.out.print( "* " );

}

System.out.println();

}

You might be interested in
Anyone have the Dell xps 13 laptop? if not pls don't answer but if you do, how is it going for you?​
Nady [450]

I do and it’s going alright; would recommend. Here’s what I think in bullet points.

- Good aesthetic design. Weave-like texture is nice and somewhat opulent.

- Good performance; you can overclock the i7 CPU.

- Battery life is at the upper end of the spectrum.

- No USB Type A Ports, big downside.

- Graphics are about 1000 points above industry average (3D Mark Fire Spark)

- Uses an SSD rather than a HDD; much quicker load time.

- I’d go for the $1,899 personally; it’s worth the extra money.

Thanks.

3 0
3 years ago
Read 2 more answers
What are human made materials ?​
jok3333 [9.3K]

Answer:

Natural materials may include wood, cotton, fur, or wool. Human-made materials may include plastic, rubber, glass, and Styrofoam.

4 0
2 years ago
The following is the correct way to write a for loop
Rzqust [24]

Answer:

for i in range

Explanation:

This is the only excerpt of code

3 0
2 years ago
1 the background image on the desktop of computer is called
aleksandrvk [35]

Answer:

4. Wallpaper

Explanation:

The background image for your computer is called a wallpaper

5 0
3 years ago
PLEASE HELP Why is the print statement considered a function?
icang [17]

Answer:

I think...

Explanation:

because it is a reusable peice of code that accomplishes task

5 0
3 years ago
Read 2 more answers
Other questions:
  • What do you observe on the filter paper strip after 2 to 3 hours?
    8·2 answers
  • Is the disk in the C: drive fixable or removable disk
    15·2 answers
  • Select all that apply.
    10·1 answer
  • What is a segment
    12·1 answer
  • Calculate the change in RGDP if the MPC is .6 and initial spending is $500,000.
    8·1 answer
  • Help me please. i need you help​
    8·1 answer
  • Add the following numbers in abacus 2436+9214​
    8·1 answer
  • What is Japanese tradition?
    8·2 answers
  • All HTML5 webpages must begin with the HTML element _____.
    6·1 answer
  • When a derived class method has the same name as a base class method, it is often said that the derived class method ________ th
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!