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
Which of the following should be considered when conducting an audience analysis ?
lyudmila [28]
1. Think about it
2. Interview the event organizer
3. Interview audiance members
4. Survey your audience members
5. <span>Poll people similar to your audience.
</span>6. <span>Study past event archives.
</span>7. Review current event materials
8. Make observations at the event itself
9. <span>Make observations during your presentation
hope this helps</span>
6 0
3 years ago
Read 2 more answers
Melissa needs to put a topic name on her email that she will send will to her teacher . choose the name of the field
Lera25 [3.4K]

It is A. I am pretty sure

8 0
3 years ago
Read 2 more answers
What information can be determined from a device's MAC address?​
rewona [7]

Answer:

I believe it is the NIC manufacturer and the serial number of the NIC

Explanation:

5 0
3 years ago
Help me please. i need you help​
Fudgin [204]

Answer:

Can you provide the code

7 0
3 years ago
Por favor definir que es un pseudocódigo y que es un diagrama de flujo.
marusya05 [52]

Answer:

que

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Here are the codes for producer and consumer problems.
    10·1 answer
  • I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
    9·1 answer
  • All nuclear energy results in the rapid release of energy, such as in atomic bombs. true or false
    8·1 answer
  • Is this statement true or false?
    11·1 answer
  • Why do you classify computers?
    6·1 answer
  • Which of the following scenarios is an example of irrelevant media?
    11·1 answer
  • When your grounded and the only thing you can get on is a computer........................oh welllllllllllllllllllllllllllllllll
    7·1 answer
  • 1. Write a 400-500 word research report about Burke High School.
    6·1 answer
  • Write a program asks the user for an integer N and then adds up the first N odd integers. For example, if the user asks the sum
    11·1 answer
  • Does anyone have discord
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!