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]
3 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]3 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
What processing software enables the user to
Dafna11 [192]

Answer:

I think its B

Explanation:

software enables users to create and edit documents.

6 0
3 years ago
Implementing content filtering and intrusion detection/intrusion prevention systems at the Internet ingress/egress as well as di
olya-2409 [2.1K]

the correct answer is:

d. clicking on unknown e-mail attachment and files.

5 0
3 years ago
Pls help points and mark brainliest computer science
KiRa [710]

Answer:

The answer is MAC address.

Explanation:

I'm a tech kid so I love this stuff!!!

Hope this helps! Have a great day! =)

4 0
3 years ago
Which type of address is the ip address 198.162.12.254/24?
Ilya [14]
Multicast Which of the following address types is shared by multiple hosts, and is used to form groups of computers that should receive the same data stream?

Which type of address is the IP address 198.162.12.254/24?
Unicast
8 0
4 years ago
To create a numbered list, you use the numbering button in the ____ group.
Jet001 [13]
To create a numbered list, use the button in the Paragraph group
5 0
3 years ago
Other questions:
  • Which type of classroom enable students to attend lectures without being physically present with the teacher
    12·2 answers
  • To pinpoint an earthquake's location, scientists need information from how many seismometers?
    8·1 answer
  • A user calls you and says that when they try to connect to the internal website, they are prompted for authentication. The user
    14·1 answer
  • PAGE<br>DATE<br>0 What types of information should be there internet?​
    5·1 answer
  • Someone knows a good compiler for iPad? It has to be an app
    10·1 answer
  • List the steps to create a new folder in windows
    13·1 answer
  • 5) The City Jail Technologies Department is constructing an application to allow users in the Crime Analysis Unit to query data
    11·1 answer
  • Complete the program below named CountVowels so that it reads in a string, counts all the vowels in that string, and prints out
    13·1 answer
  • Your development server is experiencing heavy load conditions. Upon investigating, you discover a single program using PID 9563
    5·1 answer
  • Who would win in a fight, Noble 6 from halo reach or Master Chief??
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!