The correct format for the output this tree is shown below:
(1) Output this tree
×
×××
×××××
×××××××
×××
(2) The correct format for the Below the tree is shown below:
Below the tree (with two blank lines), output this cat. (3 pts)
/ \ / \
o o
= =
- - -
Answer:
Explanation:
We are given an Hint that:
A backslash \ in a string acts as an escape character, such as with a newline \n. So, to print an actual backslash, escape that backslash by prepending another backslash.
An Example : The following prints a single backslash: System.out.println("\\");
The main objective here is to use a Java code to interpret the above (1) Output this tree and (2) Below the tree.
So Using a Java code to interpret the Program: ASCII art ; we have:
public class AsciiArt {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Draw Tree
System.out.println(" *");
System.out.println(" ***");
System.out.println(" *****");
System.out.println("*******");
System.out.println(" ***");
//output cat
System.out.println();
System.out.println("/\\\t/\\");
System.out.println(" o o");
System.out.println(" = =")
System.out.println(" ---");
}
OUTPUT:
SEE THE ATTACHED FILE BELOW.