Java Support

Go down

Java Support

Post  xBRYCEx on Wed Apr 28, 2010 10:31 pm

just for me and Walker haha
avatar
xBRYCEx
Novice Member
Novice Member

Posts : 202
Join date : 2010-04-21
Age : 27
Location : Southport NC

View user profile http://www.myspace.com\zipzen44

Back to top Go down

Re: Java Support

Post  Walker on Thu Apr 29, 2010 12:44 am

wow
avatar
Walker
Admin

Posts : 187
Join date : 2010-02-25
Age : 25
Location : North Carolina

View user profile http://cometalkat.darkbb.com

Back to top Go down

Re: Java Support

Post  xBRYCEx on Thu Apr 29, 2010 12:55 am

you know i had too

what would you suggest for this
Code:
public class Diamond
{
    public static void main( String[] args )
    {
        int line;
        int temp;

        for (line = 1; line < 10; line++)
        {
            for (temp=1; temp<=line; temp++)
            {
                System.out.print("*");


            }

            System.out.print("\n");
        }
http://System.out.print("\n");

  for (line = 10; line > 0; line--)
        {
            for (temp=1; temp<=line; temp++)
            {
                System.out.print("*");


            }

            System.out.print("\n");
        }
System.out.print("\n");

    }

}


i got the a sorda not really diamond haha
avatar
xBRYCEx
Novice Member
Novice Member

Posts : 202
Join date : 2010-04-21
Age : 27
Location : Southport NC

View user profile http://www.myspace.com\zipzen44

Back to top Go down

Re: Java Support

Post  Walker on Thu Apr 29, 2010 6:14 am

There is a code embed function just sayin....

and I think your trying to do this:
Code:
public class Main
{

    public static void main(String args[])
    {
        int num=5;
        //D
        for(int a=1;a<=num;a++)
        {
            for (int b=1;b<=10-a;b++)
            {
                System.out.print(" ");
            }
            for (int b=1;b<=a*2-1;b++)
            {
                System.out.print("*");
            }
            System.out.print("\n");
        }
        //D
        for(int a=1;a<=num;a++)
        {
            for (int b=1;b<=a+5;b++)
            {
                System.out.print(" ");
            }
            for (int b=1;b<=10-a*2-1;b++)
            {
                System.out.print("*");
            }
            System.out.print("\n");
        }
    }
}

I can't really explain this online but,
You have to loop to print spaces (Line number) and to print the asterisks (Inverse of Line number) . Then just copy the program and do it backwards to finish off the bottom of the diamond.
avatar
Walker
Admin

Posts : 187
Join date : 2010-02-25
Age : 25
Location : North Carolina

View user profile http://cometalkat.darkbb.com

Back to top Go down

Re: Java Support

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum