Results 1 to 5 of 5
  1. #1
    manibby93 is offline Member
    Join Date
    Sep 2013
    Posts
    77
    Rep Power
    0

    Default Scalable method, using constant, to print figures; use SIZE value

    I have to write a scalable method to print the following figures. It should take user input.

    Scalable method, using constant, to print figures; use SIZE value-evil.jpg

    I learned this from a ppt, and put the numbers & stuff, but idk how to do the bottom half. The user input part...idk.
    Java Code:
    public class ScalableMethod{ 
    public static final int SIZE = 4; 
    
    public static void main(String[] args) { 
    topHalf(); 
    bottomHalf(); 
    } 
    // Prints the expanding pattern of <> for the top half of the figure. 
    public static void topHalf() { 
    for (int line = 1; line <= SIZE; line++) { 
    System.out.print("|"); 
    
    for (int space = 1; space <= (line * -2 + (2*SIZE)); space++) { 
    System.out.print(" "); 
    } 
    
    System.out.print("<>"); 
    
    for (int dot = 1; dot <= (line * 4 - 4); dot++) { 
    System.out.print("."); 
    } 
    
    System.out.print("<>"); 
    
    for (int space = 1; space <= (line * -2 + (2*SIZE)); space++) { 
    System.out.print(" "); 
    } 
    } 
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Scalable method, using constant, to print figures; use SIZE value

    The bottom half is exactly the same as the upper half just in the opposite order.

    OK can you write a program do output this:
    1
    2
    3
    4

    Could you write a program to output this
    4
    3
    2
    1

    Now can you write a program that outputs
    1
    2
    3
    4
    4
    3
    2
    1

  3. #3
    manibby93 is offline Member
    Join Date
    Sep 2013
    Posts
    77
    Rep Power
    0

    Default Re: Scalable method, using constant, to print figures; use SIZE value

    Lol. That made so much sense for some reason, lol. I feel slow. Thanks. Finally I understand you. My humor...

    I just realized that the code doesn't even show the figure in the top half, so I'll fix it, but yeah, thanks.
    Last edited by manibby93; 10-11-2013 at 03:26 AM.

  4. #4
    manibby93 is offline Member
    Join Date
    Sep 2013
    Posts
    77
    Rep Power
    0

    Default Re: Scalable method, using constant, to print figures; use SIZE value

    Can you help me w/ the user input part though??

    Now it's all functional & what-not because I added this part for the bottom half:

    Java Code:
    for (int line = SIZE; line >= 1; line--) {
    Last edited by manibby93; 10-11-2013 at 03:59 AM.

  5. #5
    manibby93 is offline Member
    Join Date
    Sep 2013
    Posts
    77
    Rep Power
    0

    Default Re: Scalable method, using constant, to print figures; use SIZE value

    Nevermind!

Similar Threads

  1. Replies: 3
    Last Post: 01-03-2011, 04:48 PM
  2. Constant size for JTextArea
    By itaipee in forum AWT / Swing
    Replies: 1
    Last Post: 12-30-2008, 05:12 PM
  3. method size is deprecated
    By oregon in forum New To Java
    Replies: 4
    Last Post: 08-05-2007, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •