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.

1 Visitor Messages

  1. I've been trying to write a program for the last 3 hours with no success. What probably should seem easy to most I'm having difficulty with. I have to print two separate patterns on the same program.

    I've selected the following two:

    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    1 2 3 4 5 6
    1 2 3 4 5 6
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1

    This is the two patters stacked up, any ideas?

    Here's what I have so far and it gets me to the first line of pattern 2:

    public class TwoPatterns {
    public static void main(String[] args) {

    for (int a = 1; a <= 6; a++) {
    for (int b = 1; b <= a; b++) {
    System.out.printf("%-4d", b);
    }
    System.out.println();
    }
    for (int c = 6; c >= 6; c--) {
    for (int d = 1; d <= c; d++) {
    System.out.printf("%-4d", d);
    }
    System.out.println();
    }
    }
    }

    any help would be so appreciated!
Showing Visitor Messages 1 to 1 of 1
About winn1me

Basic Information

About winn1me
Java Skill Level:
Beginner

Statistics


Total Posts
Total Posts
3
Posts Per Day
0.00
Visitor Messages
Total Messages
1
Most Recent Message
November 14th, 2013 12:19 AM
Total Thanks
Total Thanks
1
  • Thanked 0 Times in 0 Posts
General Information
Last Activity
November 14th, 2013 06:59 PM
Join Date
November 14th, 2013