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
Mila [183]
2 years ago
5

Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another s

et of loops that displays Pattern B. Once again no setw implementation is allowed here but you must use nested loop or for statements with proper indentation to generate these patterns. Use meaningful variable identifier names, good prompting messages and appropriate comments for each loop segment as well as other sections in the body of your program.
Note: Each triangle has exactly seven rows and the width of each row is an odd number. The triangles have appropriate labels displayed.


Pattern A

+

+++

+++++

+++++++

+++++++++

+++++++++++

+++++++++++++

Pattern B

+++++++++++++

+++++++++++

+++++++++

+++++++

+++++

+++

+
Computers and Technology
1 answer:
JulsSmile [24]2 years ago
8 0

Answer:

public class Pyramid {

   public static void main(String[] args) {

             int h = 7;

       System.out.println("Pattern A");

               for(int i = 1; i <= h; ++i)

               {

                   for(int j = 1; j <= i; ++j) {

                       System.out.print("+");

                   }

                   System.out.println();

               }

       System.out.println();

       System.out.println("Pattern B");

               for (int i = 1; i<=h; ++i)

               {

                 for(int j = h; j >=i; --j){

                     System.out.print("+");

                 }

                   System.out.println();

               }

           }

       }

Explanation:

  • The trick in this code is using a nested for loop
  • The outer for loop runs from i = 0 to the heigth of the triangle (in this case 7)
  • The inner for loop which prints the (+) sign runs from j = 0 to j<=i
  • It prints the + using the print() function and not println()
  • In the pattern B the loop is reversed to start from  i = height
You might be interested in
True or false. Embedding only part of a font is called presetting.
svetoff [14.1K]
The answer is actually false. Embedding only part of a font is called Subsetting. 
8 0
3 years ago
Which of the following is no longer necessary when you use HTML5 to develop Webpages? Please Hurry This Is For An Assignment due
zlopas [31]

Answer:

Installing a third-party plug-in to include video

Explanation:

5 0
2 years ago
Alexis plans to stop trading once she lose 5% of her account balance, her account balance is $215.00. How much money is she will
irina1246 [14]

Answer:

She's willing to lose $10.75.

Explanation:

$215.00 * .05 = answer

         or

$215.00 * .95 = x

$215.00 - x = answer

7 0
2 years ago
Which of the following expressions is not equivalent to X ' ?
damaskus [11]

Answer:

the answer is going to be c

8 0
2 years ago
Is Conflict Healthy ?<br>​
Vesna [10]

yes

Explanation:

because it has more things

6 0
2 years ago
Read 2 more answers
Other questions:
  • When you send an echo request message with the ping program, a successful attempt will return a(n) ______ message.
    8·1 answer
  • Which one of these variables has an illegal name?
    11·1 answer
  • Which type of network topology has a central networking device which manages the network and acts as a communications conduit fo
    7·1 answer
  • What is the computer that is similar to a destop but smaller in size
    8·1 answer
  • ---------------is a systematic review of a person’swork and achievements over a recent period, usually leading toplans for the f
    11·1 answer
  • Select the correct answer.
    5·2 answers
  • 2 red and 2 overlapping balls in the center are surrounded by a green, fuzzy, circular cloud with a white line running through i
    15·2 answers
  • You can put ______ on your phone.
    10·1 answer
  • SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SUSSY SU
    6·2 answers
  • You are the security analyst for your organization and have discovered evidence that someone is attempting to brute-force the ro
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!