Question: Write a program that produces the figures like the following. It's a bit like a spinning top sitting on a base. Use a class constant
Write a program that produces the figures like the following. It's a bit like a spinning top sitting on a base. Use a class constant for the size of the figure. The example is for size 4. Your program should work for sizes from 2 up. The constant defines the number of rows in each section of the figure and the maximum width of the figure is 2 * the constant. Use several static methods to make the program understandable and avoid redundancy. Start by thinking about the "parts" of the drawing, something like stick, top of top, middle of top, etc. The "stick" at the top and the top and bottom of the top have the constant size number of lines; there's only one line in the middle. The "bottom stick" has twice the number of lines as the constant size, and the top base has the constant size number of lines. You'll have to figure out how to indent the various pieces of the figure with the correct number of spaces and how to adjust the number of characters in the various pieces of the top when the size changes. Be sure to try a few different sizes when running your program, at least 2, 4, and any odd number.
Java
%% !! ||| Il !! !! ||| ||| II !! !! 11 * * Il I! = 11 || II *|| ?? I! I! II II 11 li II Il I! II II II ii 11 Il ||| 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
