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
How to understand amortized analysis potential?
MA_775_DIABLO [31]
Since you gave kind of a vague question. I'll just go with the basics. Amortized analysis in computer science is basically the study of worst case run times regarding a sequence of operations.

When looking at potential, it is the physicist's method.
phi (initial state) =0 and every state after is larger than 0.
It keeps track of time but relies on states to know where it is.

The equation C +phi (state')-phi(state) is the main equation. C is the time for an operation, "state" is before and "state'" is after.

There are sets of equations that dictate average run time with this.

ex.
phi (H)= 2n-m. n=number of elements, m=size of array.
This equation is used to calculate the time to double the size.
4 0
3 years ago
What is the primary purpose of endnotes?
mihalych1998 [28]

Answer:

They acknowledge the source of a quotation, paraphrase, or summary; and (2) They provide explanatory comments that would interrupt the flow of the main text.so its B

5 0
3 years ago
Read 2 more answers
The following code should take a number as input, multiply it by 8, and print the result. In line 2 of the code below, the * sym
Juli2301 [7.4K]

Answer:

num = int(input("enter a number:"))

print(num * 8)

Explanation:

num is just a variable could be named anything you want.

if code was like this num = input("enter a number:")

and do a print(num * 8)

we get an error because whatever the user puts in input comes out a string.

we cast int() around our input() function to convert from string to integer.

therefore: num = int(input("enter a number:"))

will allow us to do  print(num * 8)

6 0
3 years ago
Which option is used in emails to inform the recipient that they should exercise discretion in accordance with sharing the conte
Kay [80]
Priority levels hehe good luck!
5 0
3 years ago
Which device protects computer systems from voltage fluctuations?
meriva
A fuse protects computer system from voltage fluctuations
6 0
3 years ago
Read 2 more answers
Other questions:
  • What type of Windows Server is the most likely server to be targeted by a computer hacker?
    13·2 answers
  • Web pages with personal or biograpic information are called ​
    10·1 answer
  • A company decides to reduce its IT labor force by hiring an external company to manage various aspects of IT administration, suc
    6·1 answer
  • This type of peripheral is used to interact with, or send data to, the computer.
    12·2 answers
  • Which of the following is a narrative essay most like?
    10·2 answers
  • How does this app work?
    11·2 answers
  • What is the computer that is similar to a destop but smaller in size
    8·1 answer
  • Which of the following scenarios is an example of irrelevant media?
    11·1 answer
  • Explain briefly why it is sometimes necessary to roll software back to a previous version, a procedure called "software
    9·1 answer
  • What is control structure write it's types​ .
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!