Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Design and implement a Java program (name it Patterns). Document your code,

ID: 3730016 • Letter: J

Question

Java

Design and implement a Java program (name it Patterns). Document your code, and organize and space the outputs. Divide your code into 4 sections, one for each pattern. Notice that your program will print the patterns one after the other, not next to each otheras shown in the textbook. Use escape characters and formatting objects when applicable. (Display four patterns using loops) Use nested loops that display the following patterns in four separate programs:

Pattern A Pattern B Pattern C Pattern D

1 123456 1 123456
12 12345 21 12345
123 1234 321 1234
1234 123 4321 123

12345 12 54321 12

123456 1 654321 1

Explanation / Answer

*note: I have provided the code for printing patterns, now you can combine them as per your requirement

//pattern A

import java.util.*;

public class PatternA {

public static void main (String[] args)

{

for(int i=0;i<6;i++)

{

for(int j=0;j<=i;j++)

System.out.print(j+1);

System.out.println("");

}

}

}

//pattern B

import java.util.*;

public class PatternB{

public static void main (String[] args)

{

for(int i=5;i>=0;i--)

{

for(int j=0;j<=i;j++)

System.out.print(j+1);

System.out.println("");

}

}

}

//pattern C

import java.util.*;

public class PatternC{

public static void main (String[] args)

{

for(int i=0;i<6;i++)

{

for(int j=0;j<=i;j++)

System.out.print(i-j+1);

System.out.println("");

}

}

}

//Pattern D

import java.util.*;

public class PatternD {

public static void main (String[] args)

{

int t =0;

for (int i=1; i<=6; i++) {

for (int k=0; k<i; k++) {

System.out.print(" ");

}

for (int j=6; j>=i;j--) {

System.out.print((t+1)+" ");

t++;

}

t=0;

System.out.println("");

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote