Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be in java please write out comments and code for me In this laboratory & assignment, you will draw a series of 16 dot

must be in java please write out comments and code for me image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this laboratory \& assignment, you will draw a series of 16 dot patterns using nested for loops. You may think of the dot patterns as geometric puzzles to be solved using loop structures. Compiling \& Running: Assume you are using java compiler and java virtual machine in command-line as follows: - Using java compiler and java virtual machine in command-line: Open the command line by typing cmd in "search programs and files" window; then, go into your working directory, compile, and run it. For example, > cd Desktoplcosc1437\Lab Assignment JDots\ javac Dots.java java Dots These are Windows commands. The first command goes to your working directory (i.e., folder). The second command compiles the . jaya files and creates . class files. The third command run/execute your Dots application. Otherwise, you are using TextPad as your IDE as follows: - Using TextPad: Read Dots. Java onto TextPad; then, compile and run the code through "Tools External Tools Compile Java" or "Tools External Tools Run Java Applications", respectively. Getting started When you run the program you can enter numbers for the various patterns you have to draw. In Dots. java, you will find that the shape of Pattem 1 is controlled by the following nested loop structure in the first block of the switch statement in drawPattern: switch (pattern) 1 case 1: for (row =0; row =0; col cols; col++) break; As this nested loop executes, method bigDot automatically connects each dot to the next dot that is drawn. You may ask: "Why are most of the connections horizontal lines?" The answer lies in the order in which the loops are nested. The row loop is the outer loop and the column loop is the inner loop. This means that, for each value of the row index, an entire cycle of the column Getting started When you run the program you can enter numbers for the various patterns you have to draw. In Dots. Java, you will find that the shape of Pattem 1 is controlled by the following nested loop structure in the first block of the switch statement in drawPattern: As this nested loop executes, method bigDot automatically connects each dot to the jnext dot that is drawn. You may ask: "Why are most of the connections horizontal lines?" The answer lies in the order in which the loops are nested. The row loop is the outer loop and the column loop is the inner loop. This means that, for each value of the row index, an entire cycle of the column loop must be executed. Therefore, for each row, the inner column loop draws a dot in column 0 , then in column 1 , and so on through column 7 . This explains why the dots in each row are connected by a sequence of horizontal lines. When a given row is finished the last dot drawn is in column 7 . The next row begins with a dot in column 0 . Therefore, the diagonal line from upper right to lower left is drawn to depict the two successive rows. The method bigDot (row, col) arranges the details of drawing the dots and making the lines which connect successive dots. Since these details are not the main focus of this exercise, we will not discuss them here. Your Task Your task is to draw the remaining 15 dot puzzles by using appropriate loop structures. You should insert the code for the remaining 15 patterns as blocks in the switch statement of drawPattern. See the location in the file marked with the comment as shown below: // START OS YOUR CODE for the remaining patterns below... .11 I/ END OE YOUR CODE.. H When your solutions are entered in the switch statement, the driver routine user Loop will enable you to interactively test all of the pattems and compare them against the solutions. Each puzzle requires giving a new twist to the loop structures. For example, in puzzles 3 to 6 , you must figure out how to replace the constants 0 and 8 in the inner loop by expressions which depend on the row index. In some of the later puzzles, you will need a sequence of loop constructs since a single nested loop structure will not be sufficient. In a few cases, you will need an extra loop variable besides row and col. However, try to use as few loops as possible, and no additional instructions besides 'for' loops

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

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What is competitive disadvantage? Why has it emerged as a factor?

Answered: 1 week ago

Question

Describe the steps involved in coaching to improve poor performance

Answered: 1 week ago

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago