Write a Java program that generates the following output. Use static methods to show structure and eliminate redundancy in your solution. Note that there are two rocket ships next to each other. What redundancy can youelimi nate using static methods? What redundancy cannot be eliminated?
Program:
public class Ch01Ex10
{
public static void main(String[] args)
{
printArrow();
printSquare();
printMessage();
printSquare();
printArrow();
}
public static void printArrow()
{
System.out.println(" /\\ /\\");
System.out.println(" / \\ / \\");
System.out.println(" / \\ / \\");
}
public static void printSquare()
{
System.out.println("+------+ +------+");
System.out.println("| | | |");
System.out.println("| | | |");
System.out.println("+------+ +------+");
}
public static void printMessage()
{
System.out.println("|United| |United|");
System.out.println("|States| |States|");
}
}
Output: