Results 1 to 3 of 3
  1. #1
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

    Post Help (java eclipse loop)

    It was suppose to be inputing a triangle which should be look like this:

    *
    **
    ***
    ****
    *****
    ******
    *****
    ****
    ***
    **
    *

    I've done this before but my little sis accidentally pressed the AVR power and TADA all my hard work was killed.

    CODE:

    public class Loopcrap
    {
    public static void main(String [] args)
    {
    int ctr1, ctr2, ctr3;
    for(ctr1=0;ctr1<=5;ctr1++){
    for(ctr2=0;ctr2<=ctr1;ctr2++){
    System.out.print("*");
    }
    System.out.println("");
    }
    /* The code was here that was suppose to input:
    *****
    ****
    ***
    **
    *
    it is also a loop.
    */
    }
    }

    Output:
    *
    **
    ***
    ****
    *****
    ******

  2. #2
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

    Default Re: Help (java eclipse loop)

    Help me!!!!!!!!!!!!!!!!!!!! Anyone! Please!

  3. #3
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

    Default Re: Help (java eclipse loop)

    Nevermind, got it all fixed :)!

    public class Loopcrap
    {
    public static void main(String [] args)
    {
    int ctr1, ctr2, ctr3;
    for(ctr1=0;ctr1<=5;ctr1++){
    for(ctr3=4;ctr3>=ctr1;ctr3--){
    System.out.print(" ");
    }
    for(ctr2=0;ctr2<=ctr1;ctr2++){
    System.out.print("*");
    }
    System.out.println("");
    }



    for(ctr1=4;ctr1>=0;ctr1--){
    for(ctr3=4; ctr3>=ctr1; ctr3--){
    System.out.print(" ");
    }
    for(ctr2=0;ctr2<=ctr1;ctr2++){
    System.out.print("*");
    }
    System.out.println("");
    }

    }
    }

Similar Threads

  1. Replies: 2
    Last Post: 10-11-2013, 09:26 AM
  2. Using while loop in Java?
    By popeyito18 in forum New To Java
    Replies: 4
    Last Post: 06-26-2011, 02:15 AM
  3. for loop in java
    By newjava in forum New To Java
    Replies: 7
    Last Post: 12-16-2009, 10:39 AM
  4. Java: While loop help
    By alfredoooddd in forum New To Java
    Replies: 3
    Last Post: 11-05-2008, 03:48 AM
  5. Help, loop with java
    By cachi in forum New To Java
    Replies: 5
    Last Post: 08-01-2007, 06:03 AM

Posting Permissions

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