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
You have spent $4,000 on liquor for your bar. Your bar sales have been $24,000. What is your cost of sales for liquor, expressed
amid [387]

Answer:

17%

Explanation:

Given parameters:

Cost price of liquor = $4000

Total sale = $24000

Unknown:

Percentage cost of sale for liquor = ?

Solution:

To find the percentage cost of sale;

       %Cost of sale of liquor = \frac{cost price of liquor}{Total cost of sale }   x 100

Input the variables;

       %Cost of sale of liquor = \frac{4000}{24000}  x 100 = 16.67% = 17%

8 0
2 years ago
How did machines get involved throughout the years?
Nataliya [291]

Answer:

Although the primary goal of a political machine is keeping itself in power rather than providing good government, machines have been responsible for restructuring city governments to centralize authority, improving facilities and services, helping to assimilate immigrant groups, and encouraging the growth of business and industry. Supporters of political machines say that they “work” and that consolidating power in the hands of a boss.

Explanation:a political machine is a political group in which an authoritative leader or small group command the support of a corps of supporters and businesses

4 0
2 years ago
What command can you use if you accidentally delete a sentence in your document?
damaskus [11]

Answer:

undo

Explanation:

or ctrl z

hope this helps

6 0
2 years ago
Read 2 more answers
In 1–2 sentences, describe how you would create a border around a group of cells
iragen [17]
Pick one of the cells you<span> want to format and then click the down arrow beside the </span>Borders<span> button in the Font </span>group<span> on the Home tab. A drop-down menu comes up with all the</span>border<span> options that </span>you can<span> apply to the </span>cell<span> selection</span>
4 0
3 years ago
Read 2 more answers
On what basis can you categorize the generations of computers?
den301095 [7]
I basically agree with the answer B.
8 0
3 years ago
Other questions:
  • What are the synonyms for each word? :
    5·1 answer
  • What is anatomy of software house?
    10·1 answer
  • What is the target audience for this poster?
    5·2 answers
  • .The __________ comes in handy when I'm using Microsoft Word to type an essay with a specific word number requirement
    6·1 answer
  • According to the municipal solid waste report what are the benefits of recycling
    6·1 answer
  • What is the best temperature to set your air conditioner on?
    12·1 answer
  • One way to prepare for filing the PROFILE is to:
    12·2 answers
  • Why was the Internet first developed? Use details and information to explain your answer.
    6·1 answer
  • Describe how computer are used in ticket counter?​
    10·1 answer
  • The process of getting listing information displayed on numerous other websites is:________
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!