Verrrrry Basic Problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Verrrrry Basic Problem

Hybrid View

  1. #1
    HDB Guest

    Verrrrry Basic Problem


    New student
    Assignment
    Write code to render a row of asterisks to form a diamond
    *
    ***
    *****
    *******
    *********
    *******
    *****
    ***
    *
    I am really stuck at this point. Can anyone give advise. As you can see I
    am a novice and have a long way to go. This one has me stumped. I know there
    are several ways to do this but what is simple and quick.
    Any sugestions are much appreciated.
    Tks,
    HDB

  2. #2
    jb Guest

    Re: Verrrrry Basic Problem

    The easiest method is to utilize some kind of loop. There are if
    statements, while statements, etc.... If you put forth some effort (eg.
    something other than 'do it for me') then you are more likely to get
    feedback. There are many websites that have information that will help you
    with loops. We normally don't do homework assignments here.


    "HDB" <dbuster@wwisp.com> wrote in message news:3a7e8094$1@news.devx.com...
    >
    > New student
    > Assignment
    > Write code to render a row of asterisks to form a diamond
    > *
    > ***
    > *****
    > *******
    > *********
    > *******
    > *****
    > ***
    > *
    > I am really stuck at this point. Can anyone give advise. As you can see I
    > am a novice and have a long way to go. This one has me stumped. I know

    there
    > are several ways to do this but what is simple and quick.
    > Any sugestions are much appreciated.
    > Tks,
    > HDB




  3. #3
    Paul Clapham Guest

    Re: Verrrrry Basic Problem

    >I know there
    > are several ways to do this but what is simple and quick.
    > Any sugestions are much appreciated.


    Suggestion: choose one of the ways to do it and start working on that.




  4. #4
    bhupesh Guest

    Re: Verrrrry Basic Problem


    "HDB" <dbuster@wwisp.com> wrote:
    >
    >New student
    >Assignment
    >Write code to render a row of asterisks to form a diamond
    > *
    > ***
    > *****
    > *******
    > *********
    > *******
    > *****
    > ***
    > *
    >I am really stuck at this point. Can anyone give advise. As you can see

    I
    >am a novice and have a long way to go. This one has me stumped. I know there
    >are several ways to do this but what is simple and quick.
    >Any sugestions are much appreciated.
    >Tks,
    >HDB

    thanks 4 posting this problem
    as a beginner i find it quite interesting
    it took me 3 hrs to debug & run this problem
    i have tried to solve it in a way i found it easy
    i dont know whether there r further any easy solutions to it


    public class Ast
    {
    static int i,j;
    //static int l=18,k=1,m=9;
    public static void main(String arg[])
    {
    int l=18,k=1,m=11;

    do
    {
    for( i=l ;i>9;i--) //i & l for leaving spaces in start
    System.out.print(" ");
    for( j=m;j<12;j++) //j & m for printing "*"
    System.out.print("*");
    System.out.println();
    l--;
    m-=2;
    k++;
    }while(k<6);
    /*System.out.println("m"+m);
    System.out.println("l"+l);
    System.out.println("k"+k);
    System.out.println("j"+j);
    System.out.println("i"+i); */
    k=1;
    do
    {
    for(int i=l-1 ;i<18;i++)
    System.out.print(" ");
    for( int j=m;j<8;++j)
    System.out.print("*");
    System.out.println();
    l--;
    m+=2;
    k++;
    }while(k<5); }}



































Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center