Question: Need help writing a java program that will do the following.. Goal: Student assessment of prerequisite skills, particularly in the areas of conditionals statements, looping

Need help writing a java program that will do the following..

Goal: Student assessment of prerequisite skills, particularly in the areas of conditionals statements, looping statements, functions/methods, and applied mathematics.

Directions: In groups of 2-3 students attempt to solve the programming challenges below. After solving ask the instructor to verify correctness.

Part 1:

Using the Java program written in class as a starting point, use your knowledge of for-loops to output to the console the following pattern. The size of the pattern should be variable (based on an int variable).

Size = 4

X

X X

X X X

X X X X

X X X

X X

X

Size = 7

X

X X

X X X

X X X X

X X X X X

X X X X X X

X X X X X X X

X X X X X X

X X X X X

X X X X

X X X

X X

X

Part 2:

Along the same lines as before output an X in the console. Again, the size should be variable. Make sure that the thickness of the line is also variable. Hint: java can check the absolute value of an expression by using Math.abs(expression).

Size = 10 thickness = 2

\ \ /

\ \ \ / /

\ \ \ / / /

\ \ \ / / /

\ \ X / /

X X X

/ / X \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \

Size = 10 thickness = 3

\ \ \ / /

\ \ \ \ / / /

\ \ \ \ \ / / / /

\ \ \ \ X / / / /

\ \ X X X / /

X X X X X

/ / X X X \ \

/ / / / X \ \ \ \

/ / / / / \ \ \ \

/ / / / \ \ \

Size = 20

\ \ /

\ \ \ / /

\ \ \ / / /

\ \ \ / / /

\ \ \ / / /

\ \ \ / / /

\ \ \ / / /

\ \ \ / / /

\ \ \ / / /

\ \ X / /

X X X

/ / X \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \ \

/ / / \ \

Part 3:

Add concentric rings to the output to make a bullseye pattern. Like everything before it the size should still be variable. You may assume only 3 rings but be sure to make the rings relative to the size (yes 3 rings will not fit on an X that is only 2 spaces in width but I intend for this to be larger like the examples below)

There are many ways to do this and you are welcome to find your own but the provided method might be able to help with the part. Ask any questions you need about it:

public static float distance(int x1, int y1, int x2, int y2)

{

return (float)Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

}

Size = 30 Thickness = 1.5

\ \ /

\ \ \ 0 0 0 0 0 0 0 / /

\ \ \ 0 0 0 0 0 0 0 0 0 0 0 0 / / /

\ \ \ 0 0 0 0 0 0 / / /

\ \ \ 0 0 0 0 0 0 / / /

\ \ \ / / /

0 \ \ \ / / / 0

0 0 \ \ \ 0 0 0 0 0 / / / 0 0

0 0 \ \ \ 0 0 0 0 0 0 0 0 / / / 0 0

0 0 \ \ \ 0 0 / / / 0 0

0 \ \ \ / / / 0

0 0 0 \ \ \ / / / 0 0 0

0 0 0 \ \ \ 0 0 0 / / / 0 0 0

0 0 0 0 \ \ \ / / / 0 0 0 0

0 0 0 0 0 \ \ X / / 0 0 0 0 0

0 0 0 X X X 0 0 0

0 0 0 0 0 / / X \ \ 0 0 0 0 0

0 0 0 0 / / / \ \ \ 0 0 0 0

0 0 0 / / / 0 0 0 \ \ \ 0 0 0

0 0 0 / / / \ \ \ 0 0 0

0 / / / \ \ \ 0

0 0 / / / 0 0 \ \ \ 0 0

0 0 / / / 0 0 0 0 0 0 0 0 \ \ \ 0 0

0 0 / / / 0 0 0 0 0 \ \ \ 0 0

0 / / / \ \ \ 0

/ / / \ \ \

/ / / 0 0 0 0 0 0 \ \ \

/ / / 0 0 0 0 0 0 \ \ \

/ / / 0 0 0 0 0 0 0 0 0 0 0 0 \ \ \

/ / / 0 0 0 0 0 0 0 \ \

Size = 40 Thickness = 2.5

\ \ \ / /

\ \ \ \ / / /

\ \ \ \ \ 0 0 0 0 0 0 0 0 0 / / / /

\ \ \ \ \ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 / / / / /

\ \ \ \ \ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 / / / / /

\ \ \ \ \ 0 0 0 0 0 0 0 0 0 0 / / / / /

\ \ \ \ \ 0 0 0 0 0 0 0 0 / / / / /

\ \ \ \ \ 0 0 / / / / /

\ \ \ \ \ 0 0 0 0 0 0 0 / / / / /

0 \ \ \ \ \ 0 0 0 0 0 0 0 0 0 0 0 / / / / / 0

0 0 0 \ \ \ \ \ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 / / / / / 0 0 0

0 0 0 \ \ \ \ \ 0 0 0 0 / / / / / 0 0 0

0 0 0 \ \ \ \ \ / / / / / 0 0 0

0 0 0 0 \ \ \ \ \ 0 0 0 0 0 / / / / / 0 0 0 0

0 0 0 0 0 \ \ \ \ \ 0 0 0 0 0 0 0 / / / / / 0 0 0 0 0

0 0 0 0 0 \ \ \ \ \ 0 0 0 0 / / / / / 0 0 0 0 0

0 0 0 0 0 \ \ \ \ \ / / / / / 0 0 0 0 0

0 0 0 0 0 0 0 \ \ \ \ \ / / / / / 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 \ \ \ \ X / / / / 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 \ \ X X X / / 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 X X X X X 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 / / X X X \ \ 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 / / / / X \ \ \ \ 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 / / / / / \ \ \ \ \ 0 0 0 0 0 0 0

0 0 0 0 0 / / / / / \ \ \ \ \ 0 0 0 0 0

0 0 0 0 0 / / / / / 0 0 0 0 \ \ \ \ \ 0 0 0 0 0

0 0 0 0 0 / / / / / 0 0 0 0 0 0 0 \ \ \ \ \ 0 0 0 0 0

0 0 0 0 / / / / / 0 0 0 0 0 \ \ \ \ \ 0 0 0 0

0 0 0 / / / / / \ \ \ \ \ 0 0 0

0 0 0 / / / / / 0 0 0 0 \ \ \ \ \ 0 0 0

0 0 0 / / / / / 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \ 0 0 0

0 / / / / / 0 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \ 0

/ / / / / 0 0 0 0 0 0 0 \ \ \ \ \

/ / / / / 0 0 \ \ \ \ \

/ / / / / 0 0 0 0 0 0 0 0 \ \ \ \ \

/ / / / / 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \

/ / / / / 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \

/ / / / / 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \

/ / / / / 0 0 0 0 0 0 0 0 0 \ \ \ \

/ / / / \ \ \

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!