Question: Write program in Java that produces the number pyramids as shown below: The programs must prompt the user for how many lines to generate. Your

Write program in Java that produces the number pyramids as shown below:

Write program in Java that produces the number pyramids as shown below: 

The programs must prompt the user for how many lines to generate. Your program must be able to generate properly formatted output regardless of the number of lines requested. Notice that the formatting of the output is based upon the maximum number generated in each of the pyramids. The number generated will not be larger than a Long.

You can convert a number to a string like: String str = "" + value;

The format specifier for formatted output (System.out.printf) can be a String variable. You'll need to do this to make sure the output is formatted based on the size of the numbers.

Enter the number of lines: 8 1 24 2 1 1 248 16 8 4 21 1 2 4 8 16 32 16 8 4 2 1 1 2 4 8 16 32 64 32 16 84 2 1 1 2 4 8 16 32 64 128 64 32 16 8 4 2 1 Enter the number of lines: 12 1 2 1 2 44 2 1 1 2 816 8 4 2 1 1 2 48 16 32 16 8421 1 24816 32 64 32 16 8421 1 2 4 816 32 64 128 6432 16 8 421 1 2 48 16 32 64 128 256 128 64 32 16 8 4 21 1 2 48 16 32 64 128 256 512 256128 64 32 16 8 4 1 1 2 48 16 32 64 128 256 512 1024 512 256 128 64 32 16 8 4 21 1 2 48 16 32 64 128 256 512 1024 2048 1024 512 256 128 64 32 16 8 4 21 21

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!