In: Computer Science
Write a program that produces the following output using nested for loop in Java.
****** //////////// ******
***** //////////\\ *****
**** ////////\\\\ ****
*** //////\\\\\\ ***
** ////\\\\\\\\ **
* //\\\\\\\\\\ *
\\\\\\\\\\\\
public class NestedLoops { public static void main(String[] args) { // change these variables if you want some other pattern int numStars = 6; int numForwardSlashes = 12; int numBackwardSlashes = 0; int numLines = 3; for (int i = 0; i < numLines; i++) { for (int j = 0; j < numStars; j++) { System.out.print("*"); } System.out.print(" "); for (int j = 0; j < numForwardSlashes; j++) { System.out.print("/"); } for (int j = 0; j < numBackwardSlashes; j++) { System.out.print("\\"); } System.out.print(" "); for (int j = 0; j < numStars; j++) { System.out.print("*"); } System.out.println(); numStars--; numForwardSlashes -= 2; numBackwardSlashes += 2; } } }