Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default Exponential Shape Program

    Hi, I am making a program that will display a design. I am trying to make it look like a fish. So far I have a tail and a body. I do not know how to complete the arc. Here is the code:
    -------------------------------------------------------------------------

    package fivefifteen;
    public class fivefifteen
    {//start fivefifteen
    public static void main(String[]args)
    {//start main
    int x = 0;
    int y = 0;
    x = 0;
    y = 10;
    System.out.println();
    for(int i = 0; i<=10;i++)
    {//start for
    for(int j = 0; j<=x;j++)
    {//start another for
    System.out.print(" ");
    }//end another for
    x++;
    for(int j=0;j<=y;j++)
    {//start for
    System.out.print("_//_");
    System.out.print(" ");
    }//end for
    y--;
    System.out.println();

    }//end for
    x= 10;
    y = 0;
    System.out.println();
    for(int i = 0; i<=10;i++)
    {//start for
    for(int j = 0; j<=x;j++)
    {//start another for
    System.out.print(" ");
    }//end another for
    x--;
    for(int j=0;j<=y;j++)
    {//start for
    System.out.print("_//_");
    System.out.print(" ");
    }//end for
    y++;
    System.out.println();

    }//end for
    }//end main
    }//end fivefifteen
    -------------------------------------------------------------------------
    output:

    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_
    _//_ _//_ _//_
    _//_ _//_
    _//_

    _//_
    _//_ _//_
    _//_ _//_ _//_
    _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_
    _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_ _//_

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Take a piece of graph paper and design what you want the output to look like. Then go row by row and create println() statements to output each row with the chars and blanks to match the design on the graph paper.

  3. #3
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default Yep

    Quote Originally Posted by Norm View Post
    Take a piece of graph paper and design what you want the output to look like. Then go row by row and create println() statements to output each row with the chars and blanks to match the design on the graph paper.
    I have already done that, but the problem is that I need to do it with for loops or do while loops. It would be pretty easy to design it line by line but isn't there an easier way to do it?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    The first step is to design the output. Then figure out how to output each line of the figure starting at the top and moving down.
    You have to look at each line and write some code to output it.
    isn't there an easier way to do it?
    Are you looking for the "Draw my figure" class? There is probably one posted somewhere. Have you tried google?

Similar Threads

  1. Help with Move Shape
    By romina in forum AWT / Swing
    Replies: 2
    Last Post: 12-09-2010, 03:25 AM
  2. implementing shape
    By sidkdbl07 in forum Java 2D
    Replies: 1
    Last Post: 01-12-2008, 06:42 PM
  3. weird looking shape JButton is it possible?
    By unhurt in forum AWT / Swing
    Replies: 8
    Last Post: 11-03-2007, 09:10 AM
  4. tool to create shape frame
    By boy22 in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 04:10 AM
  5. How to change shape of JButton
    By FaRuK in forum AWT / Swing
    Replies: 1
    Last Post: 05-19-2007, 12:56 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
  •