Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java language Topics This assignment will give you practice with for loops, static methods, print / println statements and a class constant. This assignment

in java language
Topics
This assignment will give you practice with for loops, static methods, print/println statements and a class constant. This assignment is worth 15 points instead of the normal 20 points.
the method should be like this :
public static void drawBody1(){
for (int line =1; line <= HEIGHT; line++){
System.out.print("[");
for (int i =1; i <= line -1; i++){
System.out.print("-");
}
for (int i =1; i <=-1* line +(HEIGHT +1); i++){
System.out.print("\\/");
}
for (int i =1; i <= line -1; i++){
System.out.print("-");
}
System.out.println("]");
}
Details
You are going to generate output that looks like the following (height of 5):
//\\
//!!\\
//!!!!\\
//!!!!!!\\
+~~~~~~~~~~+
[\/\/\/\/\/]
[-\/\/\/\/-]
[--\/\/\/--]
[---\/\/---]
[----\/----]
[///----\\\]
[//------\\]
[/--------\]
[\/\/\/\/\/]
[-\/\/\/\/-]
[--\/\/\/--]
[---\/\/---]
[----\/----]
+~~~~~~~~~~+
//\\
//!!\\
//!!!!\\
//!!!!!!\\
Instructions
You are to write a program that can produces an ASCII Art picture.
You should use nested loops to reduce repeating code for specific characters on a given line.
You should use static methods to structure your solution in order to reduce repeating code for repetitious subfigures.
You are required to properly indent your code and will lose points if you make indentation mistakes.
You should begin by trying to reproduce the figure above exactly. Once you can reproduce this firecracker, you should introduce a class constant to your code to make your solution more flexible in order to allow firecrackers of different sizes to be produced.
Class Constant
Unlike previous programs, this program can have varying output results based on the value assigned to a single class constant. This class constant determines the height of the firecracker. The firecracker shown above has a height of 5.
Define a class constant to make it possible to change a single number in one place in the program to have it produce a corresponding figure of a different size. When you submit your code, it does not matter what the value of your constant is set at, as I will change the constant to test your code for various output results.
On any given execution your program will produce just one version of this figure.
For example, with a height of 8, the output should look like this:
//\\
//!!\\
//!!!!\\
//!!!!!!\\
//!!!!!!!!\\
//!!!!!!!!!!\\
//!!!!!!!!!!!!\\
+~~~~~~~~~~~~~~~~+
[\/\/\/\/\/\/\/\/]
[-\/\/\/\/\/\/\/-]
[--\/\/\/\/\/\/--]
[---\/\/\/\/\/---]
[----\/\/\/\/----]
[-----\/\/\/-----]
[------\/\/------]
[-------\/-------]
[//////----\\\\\\]
[/////------\\\\\]
[////--------\\\\]
[///----------\\\]
[//------------\\]
[/--------------\]
[\/\/\/\/\/\/\/\/]
[-\/\/\/\/\/\/\/-]
[--\/\/\/\/\/\/--]
[---\/\/\/\/\/---]
[----\/\/\/\/----]
[-----\/\/\/-----]
[------\/\/------]
[-------\/-------]
+~~~~~~~~~~~~~~~~+
//\\
//!!\\
//!!!!\\
//!!!!!!\\
//!!!!!!!!\\
//!!!!!!!!!!\\
//!!!!!!!!!!!!\\
Hint
This video - Complex ASCII Figures (Links to an external site.)- will help with understanding the formulaic approach to this problem, including the development of for-loops and proper use of the class constant in order to solve the problem.
Homework Submission
Comments
Include a comment at the beginning of your program with the following information and a description of the program in your own words:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

b. What are its goals and objectives?

Answered: 1 week ago