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
1) "Information systems are revolutionizing the way businesses function in the 21st century," Do you agree or disagree with this
alukav5142 [94]

Answer:

true

Explanation:

everything is computerized. banks, shopping, financial business records, ect

7 0
3 years ago
flowgorithm based on pseudocode to ask user an age it then displays message if the user's age is greater than 65 (retirement age
DerKrebs [107]

A sample pseudocode that can be used to perform the operation is:

Print "What is your age?"

If Age > 65

Print "You are of retirement age"

If input= "5"

Terminate

Else

End

<h3>What is a Pseudocode?</h3>

This refers to the plain language that makes a description of the sequence of steps used to execute a program.

Hence, we can see that based on the user request, there is the sample pseudocode that would ask for input, if the age is greater than 65, a print function would be used and the program can be terminated if a specific number (5) is put.

Read more about pseudocodes here:

brainly.com/question/24735155

#SPJ1

3 0
2 years ago
Which of the following facts determines how often a nonroot bridge or switch sends an 802.1D STP Hello BPDU message?
irinina [24]

Answer:

b. The Hello timer as configured on the root switch.

Explanation:

There are differrent timers in a switch. The root switch is the only forwarding switch in a network, while non root switches blocks traffic to  prevent looping of BPDUs in the network. Since the root switch is the only forwarding switch, all timing configuration comes from or is based on the configuration in the root.

The hello timer is no exception as the nonroot switch only sends 802.1D DTP hello BPDU messages forwarded to it by the root switch and its frequency depends on the root switch hello timer.

8 0
4 years ago
What is the relationship between CAD and CIM ?
Marat540 [252]
<span> CAM( computerised Aided Manufacture) is when you have workers being helped by computerised tools, CIM (computerised intergated manufacture) is when the whole process is computerised, in manufacture this usually uses robotic arms. These can manufacture 24/7 in needed, they can work very accurately ( they are faster and stronger than a human arm) </span>
5 0
3 years ago
Read 2 more answers
If a movie, song, or book is offered for free, is it malware?
ElenaW [278]

Answer:

Yes

Explanation: If the something is a site or app offering free downloads or streams of well-known movies, popular TV shows, big-league sports, and absorbing games, the hidden cost is probably malware.

3 0
3 years ago
Other questions:
  • Which of the following best describes why Earth’s atmosphere can support life on Earth?
    14·1 answer
  • Which address correctly represents one that is composed of two halves, one assigned to a network adapter manufacturer, and the o
    6·1 answer
  • Who was the mvp of the 1989 nba regular season
    13·1 answer
  • One part of a development team has completed an algorithm. Why is it important to share it with others on the team? Choose all t
    15·1 answer
  • When parallel parking, you should select a space that is __________ as long as your car.
    11·1 answer
  • What error occurs in the following program? #include using namespace std; int main() { int number1, number2, sum; cout &lt;&lt;
    13·1 answer
  • Write a Python program stored in a file q1.py to play Rock-Paper-Scissors. In this game, two players count aloud to three, swing
    13·1 answer
  • Abdul wants to create a header for a webpage and enters this line: Welcome to Abdul’s webpage! , but the title is smaller than w
    12·1 answer
  • Create a Python script that will compare two (2) numbers entered by the user. Refer to the attached image and to the following a
    13·1 answer
  • Imagine that you need to prepare for three end-of-term tests. What steps will you take to make sure your study time is well spen
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!