Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: i need help

  1. #1
    Junior Member somebodyonearth's Avatar
    Join Date
    Nov 2011
    Posts
    14
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default i need help

    hi can any one tell me how to get this out put this is my code and i need to use for loop :-
    *
    **
    ***
    ****
    *****
    ******
    *******
    ********
    *********
    **********



    this is my code :-


    public class star {

    public static void main(String [] args) {
    for (int i=1; i<=10;i++){
    System.out.print('*');

    for(int x=1;x<=10;x++) {


    System.out.print('*');

    }
    System.out.println ();
    }


    }


    }

  2. #2
    Junior Member somebodyonearth's Avatar
    Join Date
    Nov 2011
    Posts
    14
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i need help

    can somebody just help me? jezz whats wrong with this site

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: i need help

    Can you show what your program prints out now?

    How many *s should be printed on each line?
    How does the number of *s printed on a line relate to the row number?
    You need to use the row number to control the number of *s printed on that row.

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i need help

    class Star {
        public static void main(String[] args){
            for(int i=1; i<=10; i++){
                for(int j=1; j<=i; j++)
                    System.out.print('*');
                System.out.print("\n");
            }
        }
    }

  5. #5
    Junior Member somebodyonearth's Avatar
    Join Date
    Nov 2011
    Posts
    14
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i need help

    it will start by one * then increment it by one each row ..but my problem is that i dont know how to do it i also need to use for loop

  6. #6
    Junior Member somebodyonearth's Avatar
    Join Date
    Nov 2011
    Posts
    14
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i need help

    ow thank u it works

  7. #7
    Junior Member somebodyonearth's Avatar
    Join Date
    Nov 2011
    Posts
    14
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i need help

    can u please explain how does it work ?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: i need help

    @tommyabc SpoonFeeding the OP code instead of letting them figure out how to solve the problem is not helping them learn.
    Take a look at this: http://www.javaprogrammingforums.com...n-feeding.html