Hi, I'm writing a simple program that will print the following two patterns:
########
#######
######
#####
####
###
##
#
########
#######
######
#####
####
###
##
#
However, I've written the method for the code called printPatterns. However, I'm not sure how to call the method within the main() in order to run the program. Here's the code thus far:
import Patterns.*;
import java.io.*;
import java.util.Scanner;
import java.lang.String.*;
public class Patterns {
public void printPatterns()
{
int row=1, j=1;
char OUTPUT='#';
System.out.println();
for (row = 1; row <= 8; row++)
{
for (j = 1; j <= row - 1; j++)
{
System.out.print(" ");
}
for (j = 1; j <= 9 - row; j++)
{
System.out.print(OUTPUT);
}
System.out.println();
}
System.out.println();
for (row = 1; row <= 8; row++)
{
for (j = 1; j <= 9 - row; j++)
{
System.out.print(OUTPUT);
}
System.out.println();
}
System.out.println();
}
}
public static void main (String[] args)
{
Patterns printPattern = new Patterns();
System.out.Patterns();
}